#include <string.h>
#include <stdlib.h>
+#include <stdbool.h>
#include "main/mtypes.h"
#include "main/cpuinfo.h"
#include "main/extensions.h"
* \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it.
*/
__DRIconfig **
-driCreateConfigs(GLenum fb_format, GLenum fb_type,
+driCreateConfigs(gl_format format,
const uint8_t * depth_bits, const uint8_t * stencil_bits,
unsigned num_depth_stencil_bits,
const GLenum * db_modes, unsigned num_db_modes,
const uint8_t * msaa_samples, unsigned num_msaa_modes,
GLboolean enable_accum)
{
- static const uint8_t bits_table[4][4] = {
- /* R G B A */
- { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */
- { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */
- { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */
+ static const uint32_t masks_table[][4] = {
+ /* MESA_FORMAT_RGB565 */
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 },
+ /* MESA_FORMAT_XRGB8888 */
+ { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 },
+ /* MESA_FORMAT_ARGB8888 */
+ { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 },
};
- static const uint32_t masks_table_rgb[6][4] = {
- { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */
- { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */
- { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000 }, /* 8_8_8_8 */
- { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 } /* 8_8_8_8_REV */
- };
-
- static const uint32_t masks_table_rgba[6][4] = {
- { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */
- { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */
- { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF }, /* 8_8_8_8 */
- { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }, /* 8_8_8_8_REV */
- };
-
- static const uint32_t masks_table_bgr[6][4] = {
- { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */
- { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */
- { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000 }, /* 8_8_8_8 */
- { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, /* 8_8_8_8_REV */
- };
-
- static const uint32_t masks_table_bgra[6][4] = {
- { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */
- { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */
- { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF }, /* 8_8_8_8 */
- { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 }, /* 8_8_8_8_REV */
- };
-
- const uint8_t * bits;
const uint32_t * masks;
- int index;
__DRIconfig **configs, **c;
struct gl_config *modes;
unsigned i, j, k, h;
unsigned num_modes;
unsigned num_accum_bits = (enable_accum) ? 2 : 1;
-
- switch ( fb_type ) {
- case GL_UNSIGNED_SHORT_5_6_5:
- index = 0;
- break;
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- index = 1;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- index = 2;
- break;
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- index = 3;
- break;
- default:
- fprintf( stderr, "[%s:%u] Unknown framebuffer type 0x%04x.\n",
- __FUNCTION__, __LINE__, fb_type );
- return NULL;
- }
-
-
- /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and
- * the _REV versions.
- *
- * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA.
- */
-
- switch ( fb_format ) {
- case GL_RGB:
- masks = masks_table_rgb[ index ];
- break;
-
- case GL_RGBA:
- masks = masks_table_rgba[ index ];
- break;
-
- case GL_BGR:
- masks = masks_table_bgr[ index ];
- break;
-
- case GL_BGRA:
- masks = masks_table_bgra[ index ];
- break;
-
- default:
- fprintf( stderr, "[%s:%u] Unknown framebuffer format 0x%04x.\n",
- __FUNCTION__, __LINE__, fb_format );
- return NULL;
+ int red_bits;
+ int green_bits;
+ int blue_bits;
+ int alpha_bits;
+ bool is_srgb;
+
+ switch (format) {
+ case MESA_FORMAT_RGB565:
+ masks = masks_table[0];
+ break;
+ case MESA_FORMAT_XRGB8888:
+ masks = masks_table[1];
+ break;
+ case MESA_FORMAT_ARGB8888:
+ masks = masks_table[2];
+ break;
+ default:
+ fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n",
+ __FUNCTION__, __LINE__,
+ _mesa_get_format_name(format), format);
+ return NULL;
}
- switch ( index ) {
- case 0:
- case 1:
- bits = bits_table[0];
- break;
- default:
- bits = ((fb_format == GL_RGB) || (fb_format == GL_BGR))
- ? bits_table[1]
- : bits_table[2];
- break;
- }
+ red_bits = _mesa_get_format_bits(format, GL_RED_BITS);
+ green_bits = _mesa_get_format_bits(format, GL_GREEN_BITS);
+ blue_bits = _mesa_get_format_bits(format, GL_BLUE_BITS);
+ alpha_bits = _mesa_get_format_bits(format, GL_ALPHA_BITS);
+ is_srgb = false;
num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits * num_msaa_modes;
configs = calloc(1, (num_modes + 1) * sizeof *configs);
c++;
memset(modes, 0, sizeof *modes);
- modes->redBits = bits[0];
- modes->greenBits = bits[1];
- modes->blueBits = bits[2];
- modes->alphaBits = bits[3];
+ modes->redBits = red_bits;
+ modes->greenBits = green_bits;
+ modes->blueBits = blue_bits;
+ modes->alphaBits = alpha_bits;
modes->redMask = masks[0];
modes->greenMask = masks[1];
modes->blueMask = masks[2];
__DRI_ATTRIB_TEXTURE_2D_BIT |
__DRI_ATTRIB_TEXTURE_RECTANGLE_BIT;
- modes->sRGBCapable = GL_FALSE;
+ modes->sRGBCapable = is_srgb;
}
}
}
static __DRIconfig**
intel_screen_make_configs(__DRIscreen *dri_screen)
{
+ static const gl_format formats[3] = {
+ MESA_FORMAT_RGB565,
+ MESA_FORMAT_XRGB8888,
+ MESA_FORMAT_ARGB8888
+ };
+
/* GLX_SWAP_COPY_OML is not supported due to page flipping. */
static const GLenum back_buffer_modes[] = {
GLX_SWAP_UNDEFINED_OML, GLX_NONE,
static const uint8_t multisample_samples[2] = {4, 8};
struct intel_screen *screen = dri_screen->driverPrivate;
- GLenum fb_format[3];
- GLenum fb_type[3];
uint8_t depth_bits[4], stencil_bits[4];
__DRIconfig **configs = NULL;
- fb_format[0] = GL_RGB;
- fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;
-
- fb_format[1] = GL_BGR;
- fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;
-
- fb_format[2] = GL_BGRA;
- fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;
-
/* Generate singlesample configs without accumulation buffer. */
- for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ for (int i = 0; i < ARRAY_SIZE(formats); i++) {
__DRIconfig **new_configs;
const int num_depth_stencil_bits = 2;
depth_bits[0] = 0;
stencil_bits[0] = 0;
- if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ if (formats[i] == MESA_FORMAT_RGB565) {
depth_bits[1] = 16;
stencil_bits[1] = 0;
} else {
stencil_bits[1] = 8;
}
- new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ new_configs = driCreateConfigs(formats[i],
depth_bits,
stencil_bits,
num_depth_stencil_bits,
/* Generate the minimum possible set of configs that include an
* accumulation buffer.
*/
- for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ for (int i = 0; i < ARRAY_SIZE(formats); i++) {
__DRIconfig **new_configs;
- if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ if (formats[i] == MESA_FORMAT_RGB565) {
depth_bits[0] = 16;
stencil_bits[0] = 0;
} else {
stencil_bits[0] = 8;
}
- new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ new_configs = driCreateConfigs(formats[i],
depth_bits, stencil_bits, 1,
back_buffer_modes, 1,
singlesample_samples, 1,
* supported. Singlebuffer configs are not supported because no one wants
* them.
*/
- for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ for (int i = 0; i < ARRAY_SIZE(formats); i++) {
if (screen->gen < 6)
break;
depth_bits[0] = 0;
stencil_bits[0] = 0;
- if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ if (formats[i] == MESA_FORMAT_RGB565) {
depth_bits[1] = 16;
stencil_bits[1] = 0;
} else {
else if (screen->gen == 6)
num_msaa_modes = 1;
- new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ new_configs = driCreateConfigs(formats[i],
depth_bits,
stencil_bits,
num_depth_stencil_bits,