aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/intel/intel_tex_format.c
blob: befa615d1e66c2154195e8a725fce37c17956acf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "intel_context.h"
#include "intel_tex.h"
#include "main/enums.h"
#include "main/formats.h"

/**
 * Returns the renderbuffer DataType for a MESA_FORMAT.
 */
GLenum
intel_mesa_format_to_rb_datatype(gl_format format)
{
   switch (format) {
   case MESA_FORMAT_ARGB8888:
   case MESA_FORMAT_XRGB8888:
   case MESA_FORMAT_SARGB8:
   case MESA_FORMAT_R8:
   case MESA_FORMAT_RG88:
   case MESA_FORMAT_A8:
   case MESA_FORMAT_I8:
   case MESA_FORMAT_L8:
   case MESA_FORMAT_AL88:
   case MESA_FORMAT_RGB565:
   case MESA_FORMAT_ARGB1555:
   case MESA_FORMAT_ARGB4444:
      return GL_UNSIGNED_BYTE;
   case MESA_FORMAT_R16:
   case MESA_FORMAT_RG1616:
   case MESA_FORMAT_Z16:
      return GL_UNSIGNED_SHORT;
   case MESA_FORMAT_X8_Z24:
      return GL_UNSIGNED_INT;
   case MESA_FORMAT_S8_Z24:
      return GL_UNSIGNED_INT_24_8_EXT;
   case MESA_FORMAT_RGBA_FLOAT32:
   case MESA_FORMAT_RG_FLOAT32:
   case MESA_FORMAT_R_FLOAT32:
   case MESA_FORMAT_INTENSITY_FLOAT32:
   case MESA_FORMAT_LUMINANCE_FLOAT32:
   case MESA_FORMAT_ALPHA_FLOAT32:
   case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
      return GL_FLOAT;

   default:
      _mesa_problem(NULL, "unexpected MESA_FORMAT for renderbuffer");
      return GL_UNSIGNED_BYTE;
   }
}

int intel_compressed_num_bytes(GLuint mesaFormat)
{
   GLuint bw, bh;
   GLuint block_size;

   block_size = _mesa_get_format_bytes(mesaFormat);
   _mesa_get_format_block_size(mesaFormat, &bw, &bh);

   return block_size / bw;
}