mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 09:20:12 +01:00
dri_util: add driImageFormatToSizedInternalGLFormat function
This is needed to implement the EXT_EGL_image_storage spec: "If <target> is GL_TEXTURE_2D, then the resultant texture must have a sized internal format which is colorspace and size compatible with the dma-buf. If the GL is unable to determine such a format, the error INVALID_OPERATION is generated." Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
This commit is contained in:
parent
b68ff2b873
commit
bf576772ab
2 changed files with 82 additions and 45 deletions
|
|
@ -875,101 +875,125 @@ driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv)
|
||||||
static const struct {
|
static const struct {
|
||||||
uint32_t image_format;
|
uint32_t image_format;
|
||||||
mesa_format mesa_format;
|
mesa_format mesa_format;
|
||||||
|
GLenum internal_format;
|
||||||
} format_mapping[] = {
|
} format_mapping[] = {
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_RGB565,
|
.image_format = __DRI_IMAGE_FORMAT_RGB565,
|
||||||
.mesa_format = MESA_FORMAT_B5G6R5_UNORM,
|
.mesa_format = MESA_FORMAT_B5G6R5_UNORM,
|
||||||
|
.internal_format = GL_RGB565,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_ARGB1555,
|
.image_format = __DRI_IMAGE_FORMAT_ARGB1555,
|
||||||
.mesa_format = MESA_FORMAT_B5G5R5A1_UNORM,
|
.mesa_format = MESA_FORMAT_B5G5R5A1_UNORM,
|
||||||
|
.internal_format = GL_RGB5_A1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_XRGB8888,
|
.image_format = __DRI_IMAGE_FORMAT_XRGB8888,
|
||||||
.mesa_format = MESA_FORMAT_B8G8R8X8_UNORM,
|
.mesa_format = MESA_FORMAT_B8G8R8X8_UNORM,
|
||||||
|
.internal_format = GL_RGBA8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_ABGR16161616F,
|
.image_format = __DRI_IMAGE_FORMAT_ABGR16161616F,
|
||||||
.mesa_format = MESA_FORMAT_RGBA_FLOAT16,
|
.mesa_format = MESA_FORMAT_RGBA_FLOAT16,
|
||||||
|
.internal_format = GL_RGBA16F,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_XBGR16161616F,
|
.image_format = __DRI_IMAGE_FORMAT_XBGR16161616F,
|
||||||
.mesa_format = MESA_FORMAT_RGBX_FLOAT16,
|
.mesa_format = MESA_FORMAT_RGBX_FLOAT16,
|
||||||
|
.internal_format = GL_RGBA16F,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_ARGB2101010,
|
.image_format = __DRI_IMAGE_FORMAT_ARGB2101010,
|
||||||
.mesa_format = MESA_FORMAT_B10G10R10A2_UNORM,
|
.mesa_format = MESA_FORMAT_B10G10R10A2_UNORM,
|
||||||
|
.internal_format = GL_RGB10_A2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_XRGB2101010,
|
.image_format = __DRI_IMAGE_FORMAT_XRGB2101010,
|
||||||
.mesa_format = MESA_FORMAT_B10G10R10X2_UNORM,
|
.mesa_format = MESA_FORMAT_B10G10R10X2_UNORM,
|
||||||
|
.internal_format = GL_RGB10_A2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_ABGR2101010,
|
.image_format = __DRI_IMAGE_FORMAT_ABGR2101010,
|
||||||
.mesa_format = MESA_FORMAT_R10G10B10A2_UNORM,
|
.mesa_format = MESA_FORMAT_R10G10B10A2_UNORM,
|
||||||
|
.internal_format = GL_RGB10_A2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_XBGR2101010,
|
.image_format = __DRI_IMAGE_FORMAT_XBGR2101010,
|
||||||
.mesa_format = MESA_FORMAT_R10G10B10X2_UNORM,
|
.mesa_format = MESA_FORMAT_R10G10B10X2_UNORM,
|
||||||
|
.internal_format = GL_RGB10_A2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_ARGB8888,
|
.image_format = __DRI_IMAGE_FORMAT_ARGB8888,
|
||||||
.mesa_format = MESA_FORMAT_B8G8R8A8_UNORM,
|
.mesa_format = MESA_FORMAT_B8G8R8A8_UNORM,
|
||||||
|
.internal_format = GL_RGBA8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_ABGR8888,
|
.image_format = __DRI_IMAGE_FORMAT_ABGR8888,
|
||||||
.mesa_format = MESA_FORMAT_R8G8B8A8_UNORM,
|
.mesa_format = MESA_FORMAT_R8G8B8A8_UNORM,
|
||||||
|
.internal_format = GL_RGBA8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_XBGR8888,
|
.image_format = __DRI_IMAGE_FORMAT_XBGR8888,
|
||||||
.mesa_format = MESA_FORMAT_R8G8B8X8_UNORM,
|
.mesa_format = MESA_FORMAT_R8G8B8X8_UNORM,
|
||||||
|
.internal_format = GL_RGBA8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_R8,
|
.image_format = __DRI_IMAGE_FORMAT_R8,
|
||||||
.mesa_format = MESA_FORMAT_R_UNORM8,
|
.mesa_format = MESA_FORMAT_R_UNORM8,
|
||||||
|
.internal_format = GL_R8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_R8,
|
.image_format = __DRI_IMAGE_FORMAT_R8,
|
||||||
.mesa_format = MESA_FORMAT_L_UNORM8,
|
.mesa_format = MESA_FORMAT_L_UNORM8,
|
||||||
|
.internal_format = GL_R8,
|
||||||
},
|
},
|
||||||
#if UTIL_ARCH_LITTLE_ENDIAN
|
#if UTIL_ARCH_LITTLE_ENDIAN
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_GR88,
|
.image_format = __DRI_IMAGE_FORMAT_GR88,
|
||||||
.mesa_format = MESA_FORMAT_RG_UNORM8,
|
.mesa_format = MESA_FORMAT_RG_UNORM8,
|
||||||
|
.internal_format = GL_RG8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_GR88,
|
.image_format = __DRI_IMAGE_FORMAT_GR88,
|
||||||
.mesa_format = MESA_FORMAT_LA_UNORM8,
|
.mesa_format = MESA_FORMAT_LA_UNORM8,
|
||||||
|
.internal_format = GL_RG8,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_SABGR8,
|
.image_format = __DRI_IMAGE_FORMAT_SABGR8,
|
||||||
.mesa_format = MESA_FORMAT_R8G8B8A8_SRGB,
|
.mesa_format = MESA_FORMAT_R8G8B8A8_SRGB,
|
||||||
|
.internal_format = GL_SRGB8_ALPHA8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_SARGB8,
|
.image_format = __DRI_IMAGE_FORMAT_SARGB8,
|
||||||
.mesa_format = MESA_FORMAT_B8G8R8A8_SRGB,
|
.mesa_format = MESA_FORMAT_B8G8R8A8_SRGB,
|
||||||
|
.internal_format = GL_SRGB8_ALPHA8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_SXRGB8,
|
.image_format = __DRI_IMAGE_FORMAT_SXRGB8,
|
||||||
.mesa_format = MESA_FORMAT_B8G8R8X8_SRGB,
|
.mesa_format = MESA_FORMAT_B8G8R8X8_SRGB,
|
||||||
|
.internal_format = GL_SRGB8_ALPHA8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_R16,
|
.image_format = __DRI_IMAGE_FORMAT_R16,
|
||||||
.mesa_format = MESA_FORMAT_R_UNORM16,
|
.mesa_format = MESA_FORMAT_R_UNORM16,
|
||||||
|
.internal_format = GL_R16,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_R16,
|
.image_format = __DRI_IMAGE_FORMAT_R16,
|
||||||
.mesa_format = MESA_FORMAT_L_UNORM16,
|
.mesa_format = MESA_FORMAT_L_UNORM16,
|
||||||
|
.internal_format = GL_R16,
|
||||||
},
|
},
|
||||||
#if UTIL_ARCH_LITTLE_ENDIAN
|
#if UTIL_ARCH_LITTLE_ENDIAN
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_GR1616,
|
.image_format = __DRI_IMAGE_FORMAT_GR1616,
|
||||||
.mesa_format = MESA_FORMAT_RG_UNORM16,
|
.mesa_format = MESA_FORMAT_RG_UNORM16,
|
||||||
|
.internal_format = GL_RG16,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.image_format = __DRI_IMAGE_FORMAT_GR1616,
|
.image_format = __DRI_IMAGE_FORMAT_GR1616,
|
||||||
.mesa_format = MESA_FORMAT_LA_UNORM16,
|
.mesa_format = MESA_FORMAT_LA_UNORM16,
|
||||||
|
.internal_format = GL_RG16,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
@ -984,6 +1008,16 @@ driGLFormatToImageFormat(mesa_format format)
|
||||||
return __DRI_IMAGE_FORMAT_NONE;
|
return __DRI_IMAGE_FORMAT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
driGLFormatToSizedInternalGLFormat(mesa_format format)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < ARRAY_SIZE(format_mapping); i++)
|
||||||
|
if (format_mapping[i].mesa_format == format)
|
||||||
|
return format_mapping[i].internal_format;
|
||||||
|
|
||||||
|
return GL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
mesa_format
|
mesa_format
|
||||||
driImageFormatToGLFormat(uint32_t image_format)
|
driImageFormatToGLFormat(uint32_t image_format)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -320,6 +320,9 @@ struct __DRIdrawableRec {
|
||||||
extern uint32_t
|
extern uint32_t
|
||||||
driGLFormatToImageFormat(mesa_format format);
|
driGLFormatToImageFormat(mesa_format format);
|
||||||
|
|
||||||
|
extern uint32_t
|
||||||
|
driGLFormatToSizedInternalGLFormat(mesa_format format);
|
||||||
|
|
||||||
extern mesa_format
|
extern mesa_format
|
||||||
driImageFormatToGLFormat(uint32_t image_format);
|
driImageFormatToGLFormat(uint32_t image_format);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue