r600g: Get rid of the state_inlines headers.
authorHenri Verbeet <hverbeet@gmail.com>
Mon, 4 Jul 2011 23:58:47 +0000 (01:58 +0200)
committerHenri Verbeet <hverbeet@gmail.com>
Mon, 4 Jul 2011 23:58:47 +0000 (01:58 +0200)
Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
src/gallium/drivers/r600/eg_state_inlines.h [deleted file]
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_inlines.h [deleted file]

diff --git a/src/gallium/drivers/r600/eg_state_inlines.h b/src/gallium/drivers/r600/eg_state_inlines.h
deleted file mode 100644 (file)
index d9f88de..0000000
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright 2010 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#ifndef EG_STATE_INLINES_H
-#define EG_STATE_INLINES_H
-
-#include "util/u_format.h"
-#include "evergreend.h"
-#include "r600_formats.h"
-
-static INLINE uint32_t r600_translate_blend_function(int blend_func)
-{
-       switch (blend_func) {
-       case PIPE_BLEND_ADD:
-               return V_028780_COMB_DST_PLUS_SRC;
-       case PIPE_BLEND_SUBTRACT:
-               return V_028780_COMB_SRC_MINUS_DST;
-       case PIPE_BLEND_REVERSE_SUBTRACT:
-               return V_028780_COMB_DST_MINUS_SRC;
-       case PIPE_BLEND_MIN:
-               return V_028780_COMB_MIN_DST_SRC;
-       case PIPE_BLEND_MAX:
-               return V_028780_COMB_MAX_DST_SRC;
-       default:
-               R600_ERR("Unknown blend function %d\n", blend_func);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_blend_factor(int blend_fact)
-{
-       switch (blend_fact) {
-       case PIPE_BLENDFACTOR_ONE:
-               return V_028780_BLEND_ONE;
-       case PIPE_BLENDFACTOR_SRC_COLOR:
-               return V_028780_BLEND_SRC_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA:
-               return V_028780_BLEND_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_DST_ALPHA:
-               return V_028780_BLEND_DST_ALPHA;
-       case PIPE_BLENDFACTOR_DST_COLOR:
-               return V_028780_BLEND_DST_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-               return V_028780_BLEND_SRC_ALPHA_SATURATE;
-       case PIPE_BLENDFACTOR_CONST_COLOR:
-               return V_028780_BLEND_CONST_COLOR;
-       case PIPE_BLENDFACTOR_CONST_ALPHA:
-               return V_028780_BLEND_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_ZERO:
-               return V_028780_BLEND_ZERO;
-       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
-               return V_028780_BLEND_ONE_MINUS_SRC_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-               return V_028780_BLEND_ONE_MINUS_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
-               return V_028780_BLEND_ONE_MINUS_DST_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_COLOR:
-               return V_028780_BLEND_ONE_MINUS_DST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
-               return V_028780_BLEND_ONE_MINUS_CONST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
-               return V_028780_BLEND_ONE_MINUS_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_SRC1_COLOR:
-               return V_028780_BLEND_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_SRC1_ALPHA:
-               return V_028780_BLEND_SRC1_ALPHA;
-       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
-               return V_028780_BLEND_INV_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-               return V_028780_BLEND_INV_SRC1_ALPHA;
-       default:
-               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_stencil_op(int s_op)
-{
-       switch (s_op) {
-       case PIPE_STENCIL_OP_KEEP:
-               return V_028800_STENCIL_KEEP;
-       case PIPE_STENCIL_OP_ZERO:
-               return V_028800_STENCIL_ZERO;
-       case PIPE_STENCIL_OP_REPLACE:
-               return V_028800_STENCIL_REPLACE;
-       case PIPE_STENCIL_OP_INCR:
-               return V_028800_STENCIL_INCR;
-       case PIPE_STENCIL_OP_DECR:
-               return V_028800_STENCIL_DECR;
-       case PIPE_STENCIL_OP_INCR_WRAP:
-               return V_028800_STENCIL_INCR_WRAP;
-       case PIPE_STENCIL_OP_DECR_WRAP:
-               return V_028800_STENCIL_DECR_WRAP;
-       case PIPE_STENCIL_OP_INVERT:
-               return V_028800_STENCIL_INVERT;
-       default:
-               R600_ERR("Unknown stencil op %d", s_op);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_fill(uint32_t func)
-{
-       switch(func) {
-       case PIPE_POLYGON_MODE_FILL:
-               return 2;
-       case PIPE_POLYGON_MODE_LINE:
-               return 1;
-       case PIPE_POLYGON_MODE_POINT:
-               return 0;
-       default:
-               assert(0);
-               return 0;
-       }
-}
-
-/* translates straight */
-static INLINE uint32_t r600_translate_ds_func(int func)
-{
-       return func;
-}
-
-static inline unsigned r600_tex_wrap(unsigned wrap)
-{
-       switch (wrap) {
-       default:
-       case PIPE_TEX_WRAP_REPEAT:
-               return V_03C000_SQ_TEX_WRAP;
-       case PIPE_TEX_WRAP_CLAMP:
-               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
-       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
-       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_CLAMP_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_REPEAT:
-               return V_03C000_SQ_TEX_MIRROR;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
-       }
-}
-
-static inline unsigned r600_tex_filter(unsigned filter)
-{
-       switch (filter) {
-       default:
-       case PIPE_TEX_FILTER_NEAREST:
-               return V_03C000_SQ_TEX_XY_FILTER_POINT;
-       case PIPE_TEX_FILTER_LINEAR:
-               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
-       }
-}
-
-static inline unsigned r600_tex_mipfilter(unsigned filter)
-{
-       switch (filter) {
-       case PIPE_TEX_MIPFILTER_NEAREST:
-               return V_03C000_SQ_TEX_Z_FILTER_POINT;
-       case PIPE_TEX_MIPFILTER_LINEAR:
-               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
-       default:
-       case PIPE_TEX_MIPFILTER_NONE:
-               return V_03C000_SQ_TEX_Z_FILTER_NONE;
-       }
-}
-
-static inline unsigned r600_tex_compare(unsigned compare)
-{
-       switch (compare) {
-       default:
-       case PIPE_FUNC_NEVER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
-       case PIPE_FUNC_LESS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
-       case PIPE_FUNC_EQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
-       case PIPE_FUNC_LEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
-       case PIPE_FUNC_GREATER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
-       case PIPE_FUNC_NOTEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
-       case PIPE_FUNC_GEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
-       case PIPE_FUNC_ALWAYS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
-       }
-}
-
-static inline unsigned r600_tex_dim(unsigned dim)
-{
-       switch (dim) {
-       default:
-       case PIPE_TEXTURE_1D:
-               return V_030000_SQ_TEX_DIM_1D;
-       case PIPE_TEXTURE_1D_ARRAY:
-               return V_030000_SQ_TEX_DIM_1D_ARRAY;
-       case PIPE_TEXTURE_2D:
-       case PIPE_TEXTURE_RECT:
-               return V_030000_SQ_TEX_DIM_2D;
-       case PIPE_TEXTURE_2D_ARRAY:
-               return V_030000_SQ_TEX_DIM_2D_ARRAY;
-       case PIPE_TEXTURE_3D:
-               return V_030000_SQ_TEX_DIM_3D;
-       case PIPE_TEXTURE_CUBE:
-               return V_030000_SQ_TEX_DIM_CUBEMAP;
-       }
-}
-
-static inline uint32_t r600_translate_dbformat(enum pipe_format format)
-{
-       switch (format) {
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028040_Z_16;
-       case PIPE_FORMAT_Z24X8_UNORM:
-               return V_028040_Z_24;
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028040_Z_24;
-       default:
-               return ~0;
-       }
-}
-
-static inline uint32_t r600_translate_stencilformat(enum pipe_format format)
-{
-       if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
-               return 1;
-       else
-               return 0;
-}
-
-static inline uint32_t r600_translate_colorswap(enum pipe_format format)
-{
-       switch (format) {
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_A8_UNORM:
-               return V_028C70_SWAP_ALT_REV;
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_028C70_SWAP_STD;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_028C70_SWAP_STD_REV;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-               return V_028C70_SWAP_ALT;
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_R16_UNORM:
-       case PIPE_FORMAT_R16_FLOAT:
-               return V_028C70_SWAP_STD;
-
-       /* 32-bit buffers. */
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-               return V_028C70_SWAP_STD_REV;
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-               return V_028C70_SWAP_ALT_REV;
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8A8_UNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
-               return V_028C70_SWAP_STD_REV;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-       case PIPE_FORMAT_R32_FLOAT:
-       case PIPE_FORMAT_R16G16_FLOAT:
-       case PIPE_FORMAT_R16G16_UNORM:
-               return V_028C70_SWAP_STD;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R32G32_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_028C70_SWAP_STD;
-       default:
-               R600_ERR("unsupported colorswap format %d\n", format);
-               return ~0;
-       }
-       return ~0;
-}
-
-static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
-{
-       switch (format) {
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_028C70_COLOR_4_4;
-
-       case PIPE_FORMAT_A8_UNORM:
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_028C70_COLOR_8;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_028C70_COLOR_5_6_5;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_028C70_COLOR_1_5_5_5;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_028C70_COLOR_4_4_4_4;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028C70_COLOR_16;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_028C70_COLOR_8_8;
-
-       case PIPE_FORMAT_R16_UNORM:
-               return V_028C70_COLOR_16;
-
-       case PIPE_FORMAT_R16_FLOAT:
-               return V_028C70_COLOR_16_FLOAT;
-
-       /* 32-bit buffers. */
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8A8_UNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-       case PIPE_FORMAT_R8G8B8_UNORM:
-               return V_028C70_COLOR_8_8_8_8;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_028C70_COLOR_2_10_10_10;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028C70_COLOR_8_24;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_028C70_COLOR_24_8;
-
-       case PIPE_FORMAT_R32_FLOAT:
-               return V_028C70_COLOR_32_FLOAT;
-
-       case PIPE_FORMAT_R16G16_FLOAT:
-               return V_028C70_COLOR_16_16_FLOAT;
-
-       case PIPE_FORMAT_R16G16_SSCALED:
-       case PIPE_FORMAT_R16G16_UNORM:
-               return V_028C70_COLOR_16_16;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-               return V_028C70_COLOR_10_11_11_FLOAT;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R16G16B16_USCALED:
-       case PIPE_FORMAT_R16G16B16A16_USCALED:
-       case PIPE_FORMAT_R16G16B16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-               return V_028C70_COLOR_16_16_16_16;
-
-       case PIPE_FORMAT_R16G16B16_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-               return V_028C70_COLOR_16_16_16_16_FLOAT;
-
-       case PIPE_FORMAT_R32G32_FLOAT:
-               return V_028C70_COLOR_32_32_FLOAT;
-
-       case PIPE_FORMAT_R32G32_USCALED:
-       case PIPE_FORMAT_R32G32_SSCALED:
-               return V_028C70_COLOR_32_32;
-
-       /* 96-bit buffers. */
-       case PIPE_FORMAT_R32G32B32_FLOAT:
-               return V_028C70_COLOR_32_32_32_FLOAT;
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_028C70_COLOR_32_32_32_32;
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-               return V_028C70_COLOR_32_32_32_32_FLOAT;
-
-       /* YUV buffers. */
-       case PIPE_FORMAT_UYVY:
-       case PIPE_FORMAT_YUYV:
-       default:
-               return ~0; /* Unsupported. */
-       }
-}
-
-static INLINE uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
-{
-       if (R600_BIG_ENDIAN) {
-               switch(colorformat) {
-               case V_028C70_COLOR_4_4:
-                       return(ENDIAN_NONE);
-
-               /* 8-bit buffers. */
-               case V_028C70_COLOR_8:
-                       return(ENDIAN_NONE);
-
-               /* 16-bit buffers. */
-               case V_028C70_COLOR_5_6_5:
-               case V_028C70_COLOR_1_5_5_5:
-               case V_028C70_COLOR_4_4_4_4:
-               case V_028C70_COLOR_16:
-               case V_028C70_COLOR_8_8:
-                       return(ENDIAN_8IN16);
-
-               /* 32-bit buffers. */
-               case V_028C70_COLOR_8_8_8_8:
-               case V_028C70_COLOR_2_10_10_10:
-               case V_028C70_COLOR_8_24:
-               case V_028C70_COLOR_24_8:
-               case V_028C70_COLOR_32_FLOAT:
-               case V_028C70_COLOR_16_16_FLOAT:
-               case V_028C70_COLOR_16_16:
-                       return(ENDIAN_8IN32);
-
-               /* 64-bit buffers. */
-               case V_028C70_COLOR_16_16_16_16:
-               case V_028C70_COLOR_16_16_16_16_FLOAT:
-                       return(ENDIAN_8IN16);
-
-               case V_028C70_COLOR_32_32_FLOAT:
-               case V_028C70_COLOR_32_32:
-                       return(ENDIAN_8IN32);
-
-               /* 96-bit buffers. */
-               case V_028C70_COLOR_32_32_32_FLOAT:
-               /* 128-bit buffers. */
-               case V_028C70_COLOR_32_32_32_32_FLOAT:
-               case V_028C70_COLOR_32_32_32_32:
-                       return(ENDIAN_8IN32);
-               default:
-                       return ENDIAN_NONE; /* Unsupported. */
-               }
-       } else {
-               return ENDIAN_NONE;
-       }
-}
-
-static INLINE boolean r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
-{
-       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0;
-}
-
-static INLINE boolean r600_is_colorbuffer_format_supported(enum pipe_format format)
-{
-       return r600_translate_colorformat(format) != ~0 &&
-               r600_translate_colorswap(format) != ~0;
-}
-
-static INLINE boolean r600_is_zs_format_supported(enum pipe_format format)
-{
-       return r600_translate_dbformat(format) != ~0;
-}
-
-#endif
index 18d54cc1e268bf9c981f3ede801646c8b807979a..887f52e67db41ec753258d9253ae79e6c3380d74 100644 (file)
 #include "r600_resource.h"
 #include "r600_shader.h"
 #include "r600_pipe.h"
-#include "eg_state_inlines.h"
+#include "r600_formats.h"
+
+static uint32_t r600_translate_blend_function(int blend_func)
+{
+       switch (blend_func) {
+       case PIPE_BLEND_ADD:
+               return V_028780_COMB_DST_PLUS_SRC;
+       case PIPE_BLEND_SUBTRACT:
+               return V_028780_COMB_SRC_MINUS_DST;
+       case PIPE_BLEND_REVERSE_SUBTRACT:
+               return V_028780_COMB_DST_MINUS_SRC;
+       case PIPE_BLEND_MIN:
+               return V_028780_COMB_MIN_DST_SRC;
+       case PIPE_BLEND_MAX:
+               return V_028780_COMB_MAX_DST_SRC;
+       default:
+               R600_ERR("Unknown blend function %d\n", blend_func);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_blend_factor(int blend_fact)
+{
+       switch (blend_fact) {
+       case PIPE_BLENDFACTOR_ONE:
+               return V_028780_BLEND_ONE;
+       case PIPE_BLENDFACTOR_SRC_COLOR:
+               return V_028780_BLEND_SRC_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA:
+               return V_028780_BLEND_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_DST_ALPHA:
+               return V_028780_BLEND_DST_ALPHA;
+       case PIPE_BLENDFACTOR_DST_COLOR:
+               return V_028780_BLEND_DST_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+               return V_028780_BLEND_SRC_ALPHA_SATURATE;
+       case PIPE_BLENDFACTOR_CONST_COLOR:
+               return V_028780_BLEND_CONST_COLOR;
+       case PIPE_BLENDFACTOR_CONST_ALPHA:
+               return V_028780_BLEND_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_ZERO:
+               return V_028780_BLEND_ZERO;
+       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+               return V_028780_BLEND_ONE_MINUS_SRC_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+               return V_028780_BLEND_ONE_MINUS_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+               return V_028780_BLEND_ONE_MINUS_DST_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_COLOR:
+               return V_028780_BLEND_ONE_MINUS_DST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+               return V_028780_BLEND_ONE_MINUS_CONST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+               return V_028780_BLEND_ONE_MINUS_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_SRC1_COLOR:
+               return V_028780_BLEND_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_SRC1_ALPHA:
+               return V_028780_BLEND_SRC1_ALPHA;
+       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+               return V_028780_BLEND_INV_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+               return V_028780_BLEND_INV_SRC1_ALPHA;
+       default:
+               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_stencil_op(int s_op)
+{
+       switch (s_op) {
+       case PIPE_STENCIL_OP_KEEP:
+               return V_028800_STENCIL_KEEP;
+       case PIPE_STENCIL_OP_ZERO:
+               return V_028800_STENCIL_ZERO;
+       case PIPE_STENCIL_OP_REPLACE:
+               return V_028800_STENCIL_REPLACE;
+       case PIPE_STENCIL_OP_INCR:
+               return V_028800_STENCIL_INCR;
+       case PIPE_STENCIL_OP_DECR:
+               return V_028800_STENCIL_DECR;
+       case PIPE_STENCIL_OP_INCR_WRAP:
+               return V_028800_STENCIL_INCR_WRAP;
+       case PIPE_STENCIL_OP_DECR_WRAP:
+               return V_028800_STENCIL_DECR_WRAP;
+       case PIPE_STENCIL_OP_INVERT:
+               return V_028800_STENCIL_INVERT;
+       default:
+               R600_ERR("Unknown stencil op %d", s_op);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_fill(uint32_t func)
+{
+       switch(func) {
+       case PIPE_POLYGON_MODE_FILL:
+               return 2;
+       case PIPE_POLYGON_MODE_LINE:
+               return 1;
+       case PIPE_POLYGON_MODE_POINT:
+               return 0;
+       default:
+               assert(0);
+               return 0;
+       }
+}
+
+/* translates straight */
+static uint32_t r600_translate_ds_func(int func)
+{
+       return func;
+}
+
+static unsigned r600_tex_wrap(unsigned wrap)
+{
+       switch (wrap) {
+       default:
+       case PIPE_TEX_WRAP_REPEAT:
+               return V_03C000_SQ_TEX_WRAP;
+       case PIPE_TEX_WRAP_CLAMP:
+               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
+       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
+       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_CLAMP_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_REPEAT:
+               return V_03C000_SQ_TEX_MIRROR;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
+       }
+}
+
+static unsigned r600_tex_filter(unsigned filter)
+{
+       switch (filter) {
+       default:
+       case PIPE_TEX_FILTER_NEAREST:
+               return V_03C000_SQ_TEX_XY_FILTER_POINT;
+       case PIPE_TEX_FILTER_LINEAR:
+               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
+       }
+}
+
+static unsigned r600_tex_mipfilter(unsigned filter)
+{
+       switch (filter) {
+       case PIPE_TEX_MIPFILTER_NEAREST:
+               return V_03C000_SQ_TEX_Z_FILTER_POINT;
+       case PIPE_TEX_MIPFILTER_LINEAR:
+               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
+       default:
+       case PIPE_TEX_MIPFILTER_NONE:
+               return V_03C000_SQ_TEX_Z_FILTER_NONE;
+       }
+}
+
+static unsigned r600_tex_compare(unsigned compare)
+{
+       switch (compare) {
+       default:
+       case PIPE_FUNC_NEVER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
+       case PIPE_FUNC_LESS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
+       case PIPE_FUNC_EQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
+       case PIPE_FUNC_LEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
+       case PIPE_FUNC_GREATER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
+       case PIPE_FUNC_NOTEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
+       case PIPE_FUNC_GEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
+       case PIPE_FUNC_ALWAYS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
+       }
+}
+
+static unsigned r600_tex_dim(unsigned dim)
+{
+       switch (dim) {
+       default:
+       case PIPE_TEXTURE_1D:
+               return V_030000_SQ_TEX_DIM_1D;
+       case PIPE_TEXTURE_1D_ARRAY:
+               return V_030000_SQ_TEX_DIM_1D_ARRAY;
+       case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
+               return V_030000_SQ_TEX_DIM_2D;
+       case PIPE_TEXTURE_2D_ARRAY:
+               return V_030000_SQ_TEX_DIM_2D_ARRAY;
+       case PIPE_TEXTURE_3D:
+               return V_030000_SQ_TEX_DIM_3D;
+       case PIPE_TEXTURE_CUBE:
+               return V_030000_SQ_TEX_DIM_CUBEMAP;
+       }
+}
+
+static uint32_t r600_translate_dbformat(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028040_Z_16;
+       case PIPE_FORMAT_Z24X8_UNORM:
+               return V_028040_Z_24;
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028040_Z_24;
+       default:
+               return ~0U;
+       }
+}
+
+static uint32_t r600_translate_stencilformat(enum pipe_format format)
+{
+       if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
+               return 1;
+       else
+               return 0;
+}
+
+static uint32_t r600_translate_colorswap(enum pipe_format format)
+{
+       switch (format) {
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_A8_UNORM:
+               return V_028C70_SWAP_ALT_REV;
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_028C70_SWAP_STD;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_028C70_SWAP_STD_REV;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+               return V_028C70_SWAP_ALT;
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_R16_UNORM:
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_028C70_SWAP_STD;
+
+       /* 32-bit buffers. */
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+               return V_028C70_SWAP_STD_REV;
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               return V_028C70_SWAP_ALT_REV;
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
+               return V_028C70_SWAP_STD_REV;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+       case PIPE_FORMAT_R32_FLOAT:
+       case PIPE_FORMAT_R16G16_FLOAT:
+       case PIPE_FORMAT_R16G16_UNORM:
+               return V_028C70_SWAP_STD;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R32G32_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_028C70_SWAP_STD;
+       default:
+               R600_ERR("unsupported colorswap format %d\n", format);
+               return ~0U;
+       }
+       return ~0U;
+}
+
+static uint32_t r600_translate_colorformat(enum pipe_format format)
+{
+       switch (format) {
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_028C70_COLOR_4_4;
+
+       case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_028C70_COLOR_8;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_028C70_COLOR_5_6_5;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_028C70_COLOR_1_5_5_5;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_028C70_COLOR_4_4_4_4;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028C70_COLOR_16;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_028C70_COLOR_8_8;
+
+       case PIPE_FORMAT_R16_UNORM:
+               return V_028C70_COLOR_16;
+
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_028C70_COLOR_16_FLOAT;
+
+       /* 32-bit buffers. */
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+       case PIPE_FORMAT_R8G8B8_UNORM:
+               return V_028C70_COLOR_8_8_8_8;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_028C70_COLOR_2_10_10_10;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028C70_COLOR_8_24;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_028C70_COLOR_24_8;
+
+       case PIPE_FORMAT_R32_FLOAT:
+               return V_028C70_COLOR_32_FLOAT;
+
+       case PIPE_FORMAT_R16G16_FLOAT:
+               return V_028C70_COLOR_16_16_FLOAT;
+
+       case PIPE_FORMAT_R16G16_SSCALED:
+       case PIPE_FORMAT_R16G16_UNORM:
+               return V_028C70_COLOR_16_16;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+               return V_028C70_COLOR_10_11_11_FLOAT;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R16G16B16_USCALED:
+       case PIPE_FORMAT_R16G16B16A16_USCALED:
+       case PIPE_FORMAT_R16G16B16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+               return V_028C70_COLOR_16_16_16_16;
+
+       case PIPE_FORMAT_R16G16B16_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+               return V_028C70_COLOR_16_16_16_16_FLOAT;
+
+       case PIPE_FORMAT_R32G32_FLOAT:
+               return V_028C70_COLOR_32_32_FLOAT;
+
+       case PIPE_FORMAT_R32G32_USCALED:
+       case PIPE_FORMAT_R32G32_SSCALED:
+               return V_028C70_COLOR_32_32;
+
+       /* 96-bit buffers. */
+       case PIPE_FORMAT_R32G32B32_FLOAT:
+               return V_028C70_COLOR_32_32_32_FLOAT;
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_028C70_COLOR_32_32_32_32;
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+               return V_028C70_COLOR_32_32_32_32_FLOAT;
+
+       /* YUV buffers. */
+       case PIPE_FORMAT_UYVY:
+       case PIPE_FORMAT_YUYV:
+       default:
+               return ~0U; /* Unsupported. */
+       }
+}
+
+static uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
+{
+       if (R600_BIG_ENDIAN) {
+               switch(colorformat) {
+               case V_028C70_COLOR_4_4:
+                       return(ENDIAN_NONE);
+
+               /* 8-bit buffers. */
+               case V_028C70_COLOR_8:
+                       return(ENDIAN_NONE);
+
+               /* 16-bit buffers. */
+               case V_028C70_COLOR_5_6_5:
+               case V_028C70_COLOR_1_5_5_5:
+               case V_028C70_COLOR_4_4_4_4:
+               case V_028C70_COLOR_16:
+               case V_028C70_COLOR_8_8:
+                       return(ENDIAN_8IN16);
+
+               /* 32-bit buffers. */
+               case V_028C70_COLOR_8_8_8_8:
+               case V_028C70_COLOR_2_10_10_10:
+               case V_028C70_COLOR_8_24:
+               case V_028C70_COLOR_24_8:
+               case V_028C70_COLOR_32_FLOAT:
+               case V_028C70_COLOR_16_16_FLOAT:
+               case V_028C70_COLOR_16_16:
+                       return(ENDIAN_8IN32);
+
+               /* 64-bit buffers. */
+               case V_028C70_COLOR_16_16_16_16:
+               case V_028C70_COLOR_16_16_16_16_FLOAT:
+                       return(ENDIAN_8IN16);
+
+               case V_028C70_COLOR_32_32_FLOAT:
+               case V_028C70_COLOR_32_32:
+                       return(ENDIAN_8IN32);
+
+               /* 96-bit buffers. */
+               case V_028C70_COLOR_32_32_32_FLOAT:
+               /* 128-bit buffers. */
+               case V_028C70_COLOR_32_32_32_32_FLOAT:
+               case V_028C70_COLOR_32_32_32_32:
+                       return(ENDIAN_8IN32);
+               default:
+                       return ENDIAN_NONE; /* Unsupported. */
+               }
+       } else {
+               return ENDIAN_NONE;
+       }
+}
+
+static bool r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
+{
+       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0U;
+}
+
+static bool r600_is_colorbuffer_format_supported(enum pipe_format format)
+{
+       return r600_translate_colorformat(format) != ~0U &&
+               r600_translate_colorswap(format) != ~0U;
+}
+
+static bool r600_is_zs_format_supported(enum pipe_format format)
+{
+       return r600_translate_dbformat(format) != ~0U;
+}
 
 boolean evergreen_is_format_supported(struct pipe_screen *screen,
                                      enum pipe_format format,
index e329317b3ab6b7437726049cd136f81f35d403f7..3085cd9a87a7c9856b431ebc45f1a523b10c7a9d 100644 (file)
 #include "r600_resource.h"
 #include "r600_shader.h"
 #include "r600_pipe.h"
-#include "r600_state_inlines.h"
+#include "r600_formats.h"
+
+static uint32_t r600_translate_blend_function(int blend_func)
+{
+       switch (blend_func) {
+       case PIPE_BLEND_ADD:
+               return V_028804_COMB_DST_PLUS_SRC;
+       case PIPE_BLEND_SUBTRACT:
+               return V_028804_COMB_SRC_MINUS_DST;
+       case PIPE_BLEND_REVERSE_SUBTRACT:
+               return V_028804_COMB_DST_MINUS_SRC;
+       case PIPE_BLEND_MIN:
+               return V_028804_COMB_MIN_DST_SRC;
+       case PIPE_BLEND_MAX:
+               return V_028804_COMB_MAX_DST_SRC;
+       default:
+               R600_ERR("Unknown blend function %d\n", blend_func);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_blend_factor(int blend_fact)
+{
+       switch (blend_fact) {
+       case PIPE_BLENDFACTOR_ONE:
+               return V_028804_BLEND_ONE;
+       case PIPE_BLENDFACTOR_SRC_COLOR:
+               return V_028804_BLEND_SRC_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA:
+               return V_028804_BLEND_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_DST_ALPHA:
+               return V_028804_BLEND_DST_ALPHA;
+       case PIPE_BLENDFACTOR_DST_COLOR:
+               return V_028804_BLEND_DST_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+               return V_028804_BLEND_SRC_ALPHA_SATURATE;
+       case PIPE_BLENDFACTOR_CONST_COLOR:
+               return V_028804_BLEND_CONST_COLOR;
+       case PIPE_BLENDFACTOR_CONST_ALPHA:
+               return V_028804_BLEND_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_ZERO:
+               return V_028804_BLEND_ZERO;
+       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+               return V_028804_BLEND_ONE_MINUS_SRC_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+               return V_028804_BLEND_ONE_MINUS_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+               return V_028804_BLEND_ONE_MINUS_DST_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_COLOR:
+               return V_028804_BLEND_ONE_MINUS_DST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+               return V_028804_BLEND_ONE_MINUS_CONST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+               return V_028804_BLEND_ONE_MINUS_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_SRC1_COLOR:
+               return V_028804_BLEND_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_SRC1_ALPHA:
+               return V_028804_BLEND_SRC1_ALPHA;
+       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+               return V_028804_BLEND_INV_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+               return V_028804_BLEND_INV_SRC1_ALPHA;
+       default:
+               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_stencil_op(int s_op)
+{
+       switch (s_op) {
+       case PIPE_STENCIL_OP_KEEP:
+               return V_028800_STENCIL_KEEP;
+       case PIPE_STENCIL_OP_ZERO:
+               return V_028800_STENCIL_ZERO;
+       case PIPE_STENCIL_OP_REPLACE:
+               return V_028800_STENCIL_REPLACE;
+       case PIPE_STENCIL_OP_INCR:
+               return V_028800_STENCIL_INCR;
+       case PIPE_STENCIL_OP_DECR:
+               return V_028800_STENCIL_DECR;
+       case PIPE_STENCIL_OP_INCR_WRAP:
+               return V_028800_STENCIL_INCR_WRAP;
+       case PIPE_STENCIL_OP_DECR_WRAP:
+               return V_028800_STENCIL_DECR_WRAP;
+       case PIPE_STENCIL_OP_INVERT:
+               return V_028800_STENCIL_INVERT;
+       default:
+               R600_ERR("Unknown stencil op %d", s_op);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_fill(uint32_t func)
+{
+       switch(func) {
+       case PIPE_POLYGON_MODE_FILL:
+               return 2;
+       case PIPE_POLYGON_MODE_LINE:
+               return 1;
+       case PIPE_POLYGON_MODE_POINT:
+               return 0;
+       default:
+               assert(0);
+               return 0;
+       }
+}
+
+/* translates straight */
+static uint32_t r600_translate_ds_func(int func)
+{
+       return func;
+}
+
+static unsigned r600_tex_wrap(unsigned wrap)
+{
+       switch (wrap) {
+       default:
+       case PIPE_TEX_WRAP_REPEAT:
+               return V_03C000_SQ_TEX_WRAP;
+       case PIPE_TEX_WRAP_CLAMP:
+               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
+       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
+       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_CLAMP_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_REPEAT:
+               return V_03C000_SQ_TEX_MIRROR;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
+       }
+}
+
+static unsigned r600_tex_filter(unsigned filter)
+{
+       switch (filter) {
+       default:
+       case PIPE_TEX_FILTER_NEAREST:
+               return V_03C000_SQ_TEX_XY_FILTER_POINT;
+       case PIPE_TEX_FILTER_LINEAR:
+               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
+       }
+}
+
+static unsigned r600_tex_mipfilter(unsigned filter)
+{
+       switch (filter) {
+       case PIPE_TEX_MIPFILTER_NEAREST:
+               return V_03C000_SQ_TEX_Z_FILTER_POINT;
+       case PIPE_TEX_MIPFILTER_LINEAR:
+               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
+       default:
+       case PIPE_TEX_MIPFILTER_NONE:
+               return V_03C000_SQ_TEX_Z_FILTER_NONE;
+       }
+}
+
+static unsigned r600_tex_compare(unsigned compare)
+{
+       switch (compare) {
+       default:
+       case PIPE_FUNC_NEVER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
+       case PIPE_FUNC_LESS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
+       case PIPE_FUNC_EQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
+       case PIPE_FUNC_LEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
+       case PIPE_FUNC_GREATER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
+       case PIPE_FUNC_NOTEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
+       case PIPE_FUNC_GEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
+       case PIPE_FUNC_ALWAYS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
+       }
+}
+
+static unsigned r600_tex_dim(unsigned dim)
+{
+       switch (dim) {
+       default:
+       case PIPE_TEXTURE_1D:
+               return V_038000_SQ_TEX_DIM_1D;
+       case PIPE_TEXTURE_1D_ARRAY:
+               return V_038000_SQ_TEX_DIM_1D_ARRAY;
+       case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
+               return V_038000_SQ_TEX_DIM_2D;
+       case PIPE_TEXTURE_2D_ARRAY:
+               return V_038000_SQ_TEX_DIM_2D_ARRAY;
+       case PIPE_TEXTURE_3D:
+               return V_038000_SQ_TEX_DIM_3D;
+       case PIPE_TEXTURE_CUBE:
+               return V_038000_SQ_TEX_DIM_CUBEMAP;
+       }
+}
+
+static uint32_t r600_translate_dbformat(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028010_DEPTH_16;
+       case PIPE_FORMAT_Z24X8_UNORM:
+               return V_028010_DEPTH_X8_24;
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028010_DEPTH_8_24;
+       default:
+               return ~0U;
+       }
+}
+
+static uint32_t r600_translate_colorswap(enum pipe_format format)
+{
+       switch (format) {
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_A8_UNORM:
+               return V_0280A0_SWAP_ALT_REV;
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_0280A0_SWAP_STD_REV;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+               return V_0280A0_SWAP_ALT;
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_R16_UNORM:
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_0280A0_SWAP_STD;
+
+       /* 32-bit buffers. */
+
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+               return V_0280A0_SWAP_STD_REV;
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               return V_0280A0_SWAP_ALT_REV;
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
+               return V_0280A0_SWAP_STD_REV;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+       case PIPE_FORMAT_R16G16_UNORM:
+       case PIPE_FORMAT_R16G16_FLOAT:
+       case PIPE_FORMAT_R32_FLOAT:
+               return V_0280A0_SWAP_STD;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R32G32_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_0280A0_SWAP_STD;
+       default:
+               R600_ERR("unsupported colorswap format %d\n", format);
+               return ~0U;
+       }
+       return ~0U;
+}
+
+static uint32_t r600_translate_colorformat(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_0280A0_COLOR_4_4;
+
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_0280A0_COLOR_8;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_0280A0_COLOR_5_6_5;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_0280A0_COLOR_1_5_5_5;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_0280A0_COLOR_4_4_4_4;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_0280A0_COLOR_16;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_0280A0_COLOR_8_8;
+
+       case PIPE_FORMAT_R16_UNORM:
+               return V_0280A0_COLOR_16;
+
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_0280A0_COLOR_16_FLOAT;
+
+       /* 32-bit buffers. */
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+       case PIPE_FORMAT_R8G8B8_UNORM:
+               return V_0280A0_COLOR_8_8_8_8;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_0280A0_COLOR_2_10_10_10;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_0280A0_COLOR_8_24;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_0280A0_COLOR_24_8;
+
+       case PIPE_FORMAT_R32_FLOAT:
+               return V_0280A0_COLOR_32_FLOAT;
+
+       case PIPE_FORMAT_R16G16_FLOAT:
+               return V_0280A0_COLOR_16_16_FLOAT;
+
+       case PIPE_FORMAT_R16G16_SSCALED:
+       case PIPE_FORMAT_R16G16_UNORM:
+               return V_0280A0_COLOR_16_16;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+               return V_0280A0_COLOR_10_11_11_FLOAT;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R16G16B16_USCALED:
+       case PIPE_FORMAT_R16G16B16A16_USCALED:
+       case PIPE_FORMAT_R16G16B16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+               return V_0280A0_COLOR_16_16_16_16;
+
+       case PIPE_FORMAT_R16G16B16_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+               return V_0280A0_COLOR_16_16_16_16_FLOAT;
+
+       case PIPE_FORMAT_R32G32_FLOAT:
+               return V_0280A0_COLOR_32_32_FLOAT;
+
+       case PIPE_FORMAT_R32G32_USCALED:
+       case PIPE_FORMAT_R32G32_SSCALED:
+               return V_0280A0_COLOR_32_32;
+
+       /* 96-bit buffers. */
+       case PIPE_FORMAT_R32G32B32_FLOAT:
+               return V_0280A0_COLOR_32_32_32_FLOAT;
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+               return V_0280A0_COLOR_32_32_32_32_FLOAT;
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_0280A0_COLOR_32_32_32_32;
+
+       /* YUV buffers. */
+       case PIPE_FORMAT_UYVY:
+       case PIPE_FORMAT_YUYV:
+       default:
+               return ~0U; /* Unsupported. */
+       }
+}
+
+static uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
+{
+       if (R600_BIG_ENDIAN) {
+               switch(colorformat) {
+               case V_0280A0_COLOR_4_4:
+                       return(ENDIAN_NONE);
+
+               /* 8-bit buffers. */
+               case V_0280A0_COLOR_8:
+                       return(ENDIAN_NONE);
+
+               /* 16-bit buffers. */
+               case V_0280A0_COLOR_5_6_5:
+               case V_0280A0_COLOR_1_5_5_5:
+               case V_0280A0_COLOR_4_4_4_4:
+               case V_0280A0_COLOR_16:
+               case V_0280A0_COLOR_8_8:
+                       return(ENDIAN_8IN16);
+
+               /* 32-bit buffers. */
+               case V_0280A0_COLOR_8_8_8_8:
+               case V_0280A0_COLOR_2_10_10_10:
+               case V_0280A0_COLOR_8_24:
+               case V_0280A0_COLOR_24_8:
+               case V_0280A0_COLOR_32_FLOAT:
+               case V_0280A0_COLOR_16_16_FLOAT:
+               case V_0280A0_COLOR_16_16:
+                       return(ENDIAN_8IN32);
+
+               /* 64-bit buffers. */
+               case V_0280A0_COLOR_16_16_16_16:
+               case V_0280A0_COLOR_16_16_16_16_FLOAT:
+                       return(ENDIAN_8IN16);
+
+               case V_0280A0_COLOR_32_32_FLOAT:
+               case V_0280A0_COLOR_32_32:
+                       return(ENDIAN_8IN32);
+
+               /* 128-bit buffers. */
+               case V_0280A0_COLOR_32_32_32_FLOAT:
+               case V_0280A0_COLOR_32_32_32_32_FLOAT:
+               case V_0280A0_COLOR_32_32_32_32:
+                       return(ENDIAN_8IN32);
+               default:
+                       return ENDIAN_NONE; /* Unsupported. */
+               }
+       } else {
+               return ENDIAN_NONE;
+       }
+}
+
+static bool r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
+{
+       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0U;
+}
+
+static bool r600_is_colorbuffer_format_supported(enum pipe_format format)
+{
+       return r600_translate_colorformat(format) != ~0U &&
+              r600_translate_colorswap(format) != ~0U;
+}
+
+static bool r600_is_zs_format_supported(enum pipe_format format)
+{
+       return r600_translate_dbformat(format) != ~0U;
+}
 
 boolean r600_is_format_supported(struct pipe_screen *screen,
                                 enum pipe_format format,
diff --git a/src/gallium/drivers/r600/r600_state_inlines.h b/src/gallium/drivers/r600/r600_state_inlines.h
deleted file mode 100644 (file)
index e9479bd..0000000
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Copyright 2010 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#ifndef R600_STATE_INLINES_H
-#define R600_STATE_INLINES_H
-
-#include "util/u_format.h"
-#include "r600d.h"
-#include "r600_formats.h"
-
-static INLINE uint32_t r600_translate_blend_function(int blend_func)
-{
-       switch (blend_func) {
-       case PIPE_BLEND_ADD:
-               return V_028804_COMB_DST_PLUS_SRC;
-       case PIPE_BLEND_SUBTRACT:
-               return V_028804_COMB_SRC_MINUS_DST;
-       case PIPE_BLEND_REVERSE_SUBTRACT:
-               return V_028804_COMB_DST_MINUS_SRC;
-       case PIPE_BLEND_MIN:
-               return V_028804_COMB_MIN_DST_SRC;
-       case PIPE_BLEND_MAX:
-               return V_028804_COMB_MAX_DST_SRC;
-       default:
-               R600_ERR("Unknown blend function %d\n", blend_func);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_blend_factor(int blend_fact)
-{
-       switch (blend_fact) {
-       case PIPE_BLENDFACTOR_ONE:
-               return V_028804_BLEND_ONE;
-       case PIPE_BLENDFACTOR_SRC_COLOR:
-               return V_028804_BLEND_SRC_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA:
-               return V_028804_BLEND_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_DST_ALPHA:
-               return V_028804_BLEND_DST_ALPHA;
-       case PIPE_BLENDFACTOR_DST_COLOR:
-               return V_028804_BLEND_DST_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-               return V_028804_BLEND_SRC_ALPHA_SATURATE;
-       case PIPE_BLENDFACTOR_CONST_COLOR:
-               return V_028804_BLEND_CONST_COLOR;
-       case PIPE_BLENDFACTOR_CONST_ALPHA:
-               return V_028804_BLEND_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_ZERO:
-               return V_028804_BLEND_ZERO;
-       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
-               return V_028804_BLEND_ONE_MINUS_SRC_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-               return V_028804_BLEND_ONE_MINUS_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
-               return V_028804_BLEND_ONE_MINUS_DST_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_COLOR:
-               return V_028804_BLEND_ONE_MINUS_DST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
-               return V_028804_BLEND_ONE_MINUS_CONST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
-               return V_028804_BLEND_ONE_MINUS_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_SRC1_COLOR:
-               return V_028804_BLEND_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_SRC1_ALPHA:
-               return V_028804_BLEND_SRC1_ALPHA;
-       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
-               return V_028804_BLEND_INV_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-               return V_028804_BLEND_INV_SRC1_ALPHA;
-       default:
-               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_stencil_op(int s_op)
-{
-       switch (s_op) {
-       case PIPE_STENCIL_OP_KEEP:
-               return V_028800_STENCIL_KEEP;
-       case PIPE_STENCIL_OP_ZERO:
-               return V_028800_STENCIL_ZERO;
-       case PIPE_STENCIL_OP_REPLACE:
-               return V_028800_STENCIL_REPLACE;
-       case PIPE_STENCIL_OP_INCR:
-               return V_028800_STENCIL_INCR;
-       case PIPE_STENCIL_OP_DECR:
-               return V_028800_STENCIL_DECR;
-       case PIPE_STENCIL_OP_INCR_WRAP:
-               return V_028800_STENCIL_INCR_WRAP;
-       case PIPE_STENCIL_OP_DECR_WRAP:
-               return V_028800_STENCIL_DECR_WRAP;
-       case PIPE_STENCIL_OP_INVERT:
-               return V_028800_STENCIL_INVERT;
-       default:
-               R600_ERR("Unknown stencil op %d", s_op);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_fill(uint32_t func)
-{
-       switch(func) {
-       case PIPE_POLYGON_MODE_FILL:
-               return 2;
-       case PIPE_POLYGON_MODE_LINE:
-               return 1;
-       case PIPE_POLYGON_MODE_POINT:
-               return 0;
-       default:
-               assert(0);
-               return 0;
-       }
-}
-
-/* translates straight */
-static INLINE uint32_t r600_translate_ds_func(int func)
-{
-       return func;
-}
-
-static inline unsigned r600_tex_wrap(unsigned wrap)
-{
-       switch (wrap) {
-       default:
-       case PIPE_TEX_WRAP_REPEAT:
-               return V_03C000_SQ_TEX_WRAP;
-       case PIPE_TEX_WRAP_CLAMP:
-               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
-       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
-       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_CLAMP_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_REPEAT:
-               return V_03C000_SQ_TEX_MIRROR;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
-       }
-}
-
-static inline unsigned r600_tex_filter(unsigned filter)
-{
-       switch (filter) {
-       default:
-       case PIPE_TEX_FILTER_NEAREST:
-               return V_03C000_SQ_TEX_XY_FILTER_POINT;
-       case PIPE_TEX_FILTER_LINEAR:
-               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
-       }
-}
-
-static inline unsigned r600_tex_mipfilter(unsigned filter)
-{
-       switch (filter) {
-       case PIPE_TEX_MIPFILTER_NEAREST:
-               return V_03C000_SQ_TEX_Z_FILTER_POINT;
-       case PIPE_TEX_MIPFILTER_LINEAR:
-               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
-       default:
-       case PIPE_TEX_MIPFILTER_NONE:
-               return V_03C000_SQ_TEX_Z_FILTER_NONE;
-       }
-}
-
-static inline unsigned r600_tex_compare(unsigned compare)
-{
-       switch (compare) {
-       default:
-       case PIPE_FUNC_NEVER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
-       case PIPE_FUNC_LESS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
-       case PIPE_FUNC_EQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
-       case PIPE_FUNC_LEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
-       case PIPE_FUNC_GREATER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
-       case PIPE_FUNC_NOTEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
-       case PIPE_FUNC_GEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
-       case PIPE_FUNC_ALWAYS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
-       }
-}
-
-static inline unsigned r600_tex_dim(unsigned dim)
-{
-       switch (dim) {
-       default:
-       case PIPE_TEXTURE_1D:
-               return V_038000_SQ_TEX_DIM_1D;
-       case PIPE_TEXTURE_1D_ARRAY:
-               return V_038000_SQ_TEX_DIM_1D_ARRAY;
-       case PIPE_TEXTURE_2D:
-       case PIPE_TEXTURE_RECT:
-               return V_038000_SQ_TEX_DIM_2D;
-       case PIPE_TEXTURE_2D_ARRAY:
-               return V_038000_SQ_TEX_DIM_2D_ARRAY;
-       case PIPE_TEXTURE_3D:
-               return V_038000_SQ_TEX_DIM_3D;
-       case PIPE_TEXTURE_CUBE:
-               return V_038000_SQ_TEX_DIM_CUBEMAP;
-       }
-}
-
-static inline uint32_t r600_translate_dbformat(enum pipe_format format)
-{
-       switch (format) {
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028010_DEPTH_16;
-       case PIPE_FORMAT_Z24X8_UNORM:
-               return V_028010_DEPTH_X8_24;
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028010_DEPTH_8_24;
-       default:
-               return ~0;
-       }
-}
-
-static inline uint32_t r600_translate_colorswap(enum pipe_format format)
-{
-       switch (format) {
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_A8_UNORM:
-               return V_0280A0_SWAP_ALT_REV;
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_0280A0_SWAP_STD_REV;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-               return V_0280A0_SWAP_ALT;
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_R16_UNORM:
-       case PIPE_FORMAT_R16_FLOAT:
-               return V_0280A0_SWAP_STD;
-
-       /* 32-bit buffers. */
-
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-               return V_0280A0_SWAP_STD_REV;
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-               return V_0280A0_SWAP_ALT_REV;
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8A8_UNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
-               return V_0280A0_SWAP_STD_REV;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-       case PIPE_FORMAT_R16G16_UNORM:
-       case PIPE_FORMAT_R16G16_FLOAT:
-       case PIPE_FORMAT_R32_FLOAT:
-               return V_0280A0_SWAP_STD;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R32G32_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_0280A0_SWAP_STD;
-       default:
-               R600_ERR("unsupported colorswap format %d\n", format);
-               return ~0;
-       }
-       return ~0;
-}
-
-static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
-{
-       switch (format) {
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_0280A0_COLOR_4_4;
-
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_A8_UNORM:
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_0280A0_COLOR_8;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_0280A0_COLOR_5_6_5;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_0280A0_COLOR_1_5_5_5;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_0280A0_COLOR_4_4_4_4;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_0280A0_COLOR_16;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_0280A0_COLOR_8_8;
-
-       case PIPE_FORMAT_R16_UNORM:
-               return V_0280A0_COLOR_16;
-
-       case PIPE_FORMAT_R16_FLOAT:
-               return V_0280A0_COLOR_16_FLOAT;
-
-       /* 32-bit buffers. */
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8A8_UNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-       case PIPE_FORMAT_R8G8B8_UNORM:
-               return V_0280A0_COLOR_8_8_8_8;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_0280A0_COLOR_2_10_10_10;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_0280A0_COLOR_8_24;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_0280A0_COLOR_24_8;
-
-       case PIPE_FORMAT_R32_FLOAT:
-               return V_0280A0_COLOR_32_FLOAT;
-
-       case PIPE_FORMAT_R16G16_FLOAT:
-               return V_0280A0_COLOR_16_16_FLOAT;
-
-       case PIPE_FORMAT_R16G16_SSCALED:
-       case PIPE_FORMAT_R16G16_UNORM:
-               return V_0280A0_COLOR_16_16;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-               return V_0280A0_COLOR_10_11_11_FLOAT;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R16G16B16_USCALED:
-       case PIPE_FORMAT_R16G16B16A16_USCALED:
-       case PIPE_FORMAT_R16G16B16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-               return V_0280A0_COLOR_16_16_16_16;
-
-       case PIPE_FORMAT_R16G16B16_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-               return V_0280A0_COLOR_16_16_16_16_FLOAT;
-
-       case PIPE_FORMAT_R32G32_FLOAT:
-               return V_0280A0_COLOR_32_32_FLOAT;
-
-       case PIPE_FORMAT_R32G32_USCALED:
-       case PIPE_FORMAT_R32G32_SSCALED:
-               return V_0280A0_COLOR_32_32;
-
-       /* 96-bit buffers. */
-       case PIPE_FORMAT_R32G32B32_FLOAT:
-               return V_0280A0_COLOR_32_32_32_FLOAT;
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-               return V_0280A0_COLOR_32_32_32_32_FLOAT;
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_0280A0_COLOR_32_32_32_32;
-
-       /* YUV buffers. */
-       case PIPE_FORMAT_UYVY:
-       case PIPE_FORMAT_YUYV:
-       default:
-               return ~0; /* Unsupported. */
-       }
-}
-
-static INLINE uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
-{
-       if (R600_BIG_ENDIAN) {
-               switch(colorformat) {
-               case V_0280A0_COLOR_4_4:
-                       return(ENDIAN_NONE);
-
-               /* 8-bit buffers. */
-               case V_0280A0_COLOR_8:
-                       return(ENDIAN_NONE);
-
-               /* 16-bit buffers. */
-               case V_0280A0_COLOR_5_6_5:
-               case V_0280A0_COLOR_1_5_5_5:
-               case V_0280A0_COLOR_4_4_4_4:
-               case V_0280A0_COLOR_16:
-               case V_0280A0_COLOR_8_8:
-                       return(ENDIAN_8IN16);
-
-               /* 32-bit buffers. */
-               case V_0280A0_COLOR_8_8_8_8:
-               case V_0280A0_COLOR_2_10_10_10:
-               case V_0280A0_COLOR_8_24:
-               case V_0280A0_COLOR_24_8:
-               case V_0280A0_COLOR_32_FLOAT:
-               case V_0280A0_COLOR_16_16_FLOAT:
-               case V_0280A0_COLOR_16_16:
-                       return(ENDIAN_8IN32);
-
-               /* 64-bit buffers. */
-               case V_0280A0_COLOR_16_16_16_16:
-               case V_0280A0_COLOR_16_16_16_16_FLOAT:
-                       return(ENDIAN_8IN16);
-
-               case V_0280A0_COLOR_32_32_FLOAT:
-               case V_0280A0_COLOR_32_32:
-                       return(ENDIAN_8IN32);
-
-               /* 128-bit buffers. */
-               case V_0280A0_COLOR_32_32_32_FLOAT:
-               case V_0280A0_COLOR_32_32_32_32_FLOAT:
-               case V_0280A0_COLOR_32_32_32_32:
-                       return(ENDIAN_8IN32);
-               default:
-                       return ENDIAN_NONE; /* Unsupported. */
-               }
-       } else {
-               return ENDIAN_NONE;
-       }
-}
-
-static INLINE boolean r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
-{
-       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0;
-}
-
-static INLINE boolean r600_is_colorbuffer_format_supported(enum pipe_format format)
-{
-       return r600_translate_colorformat(format) != ~0 &&
-              r600_translate_colorswap(format) != ~0;
-}
-
-static INLINE boolean r600_is_zs_format_supported(enum pipe_format format)
-{
-       return r600_translate_dbformat(format) != ~0;
-}
-
-#endif