r300_state_inlines.h revision ddc6ee316cd7ca07853efc615cd2681f3a1232d4
1/*
2 * Copyright 2009 Joakim Sindholt <opensource@zhasha.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_STATE_INLINES_H
24#define R300_STATE_INLINES_H
25
26#include "pipe/p_format.h"
27
28#include "r300_reg.h"
29
30static INLINE uint32_t r300_translate_colorformat(enum pipe_format format)
31{
32    switch (format) {
33    case PIPE_FORMAT_A8R8G8B8_UNORM:
34        return R300_COLOR_FORMAT_ARGB8888;
35    case PIPE_FORMAT_I8_UNORM:
36        return R300_COLOR_FORMAT_I8;
37    case PIPE_FORMAT_A1R5G5B5_UNORM:
38        return R300_COLOR_FORMAT_ARGB1555;
39    case PIPE_FORMAT_R5G6B5_UNORM:
40        return R300_COLOR_FORMAT_RGB565;
41    /* XXX Not in pipe_format
42    case PIPE_FORMAT_A32R32G32B32:
43        return R300_COLOR_FORMAT_ARGB32323232;
44    case PIPE_FORMAT_A16R16G16B16:
45        return R300_COLOR_FORMAT_ARGB16161616; */
46    case PIPE_FORMAT_A4R4G4B4_UNORM:
47        return R300_COLOR_FORMAT_ARGB4444;
48    /* XXX Not in pipe_format
49    case PIPE_FORMAT_A10R10G10B10_UNORM:
50        return R500_COLOR_FORMAT_ARGB10101010;
51    case PIPE_FORMAT_A2R10G10B10_UNORM:
52        return R500_COLOR_FORMAT_ARGB2101010;
53    case PIPE_FORMAT_I10_UNORM:
54        return R500_COLOR_FORMAT_I10; */
55    default:
56        debug_printf("r300: Implementation error: " \
57            "Got unsupported color format %s in %s\n",
58            pf_name(format), __FUNCTION__);
59        break;
60    }
61
62    return 0;
63}
64
65static INLINE uint32_t r300_translate_zsformat(enum pipe_format format)
66{
67    switch (format) {
68    case PIPE_FORMAT_Z16_UNORM:
69        return R300_DEPTHFORMAT_16BIT_INT_Z;
70    /* XXX R300_DEPTHFORMAT_16BIT_13E3 anyone? */
71    case PIPE_FORMAT_Z24S8_UNORM:
72        return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
73    default:
74        debug_printf("r300: Implementation error: " \
75            "Got unsupported ZS format %s in %s\n",
76            pf_name(format), __FUNCTION__);
77        break;
78    }
79
80    return 0;
81}
82
83#endif /* R300_STATE_INLINES_H */
84