sync with tizen_2.2
[sdk/emulator/qemu.git] / gl / mesa / src / mesa / drivers / dri / intel / intel_tex_format.c
1 #include "intel_context.h"
2 #include "intel_tex.h"
3 #include "main/enums.h"
4 #include "main/formats.h"
5
6 /**
7  * Returns the renderbuffer DataType for a MESA_FORMAT.
8  */
9 GLenum
10 intel_mesa_format_to_rb_datatype(gl_format format)
11 {
12    switch (format) {
13    case MESA_FORMAT_ARGB8888:
14    case MESA_FORMAT_XRGB8888:
15    case MESA_FORMAT_SARGB8:
16    case MESA_FORMAT_R8:
17    case MESA_FORMAT_GR88:
18    case MESA_FORMAT_A8:
19    case MESA_FORMAT_I8:
20    case MESA_FORMAT_L8:
21    case MESA_FORMAT_AL88:
22    case MESA_FORMAT_RGB565:
23    case MESA_FORMAT_ARGB1555:
24    case MESA_FORMAT_ARGB4444:
25    case MESA_FORMAT_S8:
26       return GL_UNSIGNED_BYTE;
27    case MESA_FORMAT_R16:
28    case MESA_FORMAT_RG1616:
29    case MESA_FORMAT_Z16:
30       return GL_UNSIGNED_SHORT;
31    case MESA_FORMAT_X8_Z24:
32       return GL_UNSIGNED_INT;
33    case MESA_FORMAT_S8_Z24:
34       return GL_UNSIGNED_INT_24_8_EXT;
35    case MESA_FORMAT_RGBA_FLOAT32:
36    case MESA_FORMAT_RG_FLOAT32:
37    case MESA_FORMAT_R_FLOAT32:
38    case MESA_FORMAT_INTENSITY_FLOAT32:
39    case MESA_FORMAT_LUMINANCE_FLOAT32:
40    case MESA_FORMAT_ALPHA_FLOAT32:
41    case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
42       return GL_FLOAT;
43
44       /* The core depthstencil wrappers demand this. */
45    case MESA_FORMAT_Z32_FLOAT_X24S8:
46       return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
47
48    default:
49       /* Unsupported format.  We may hit this when people ask for FBO-incomplete
50        * formats.
51        */
52       return GL_NONE;
53    }
54 }
55
56 int intel_compressed_num_bytes(GLuint mesaFormat)
57 {
58    GLuint bw, bh;
59    GLuint block_size;
60
61    block_size = _mesa_get_format_bytes(mesaFormat);
62    _mesa_get_format_block_size(mesaFormat, &bw, &bh);
63
64    return block_size / bw;
65 }