mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 03:38:06 +02:00
mesa: implement new texture format I16
This commit is contained in:
parent
bb5ace68ce
commit
fd8aa7ac71
6 changed files with 50 additions and 4 deletions
|
|
@ -320,6 +320,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
|
|||
0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
|
||||
1, 1, 1 /* BlockWidth/Height,Bytes */
|
||||
},
|
||||
{
|
||||
MESA_FORMAT_I16, /* Name */
|
||||
"MESA_FORMAT_I16", /* StrName */
|
||||
GL_INTENSITY, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED, /* DataType */
|
||||
0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
|
||||
0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
|
||||
1, 1, 2 /* BlockWidth/Height,Bytes */
|
||||
},
|
||||
{
|
||||
MESA_FORMAT_CI8, /* Name */
|
||||
"MESA_FORMAT_CI8", /* StrName */
|
||||
|
|
@ -1317,6 +1326,7 @@ _mesa_format_to_type_and_comps(gl_format format,
|
|||
case MESA_FORMAT_R16:
|
||||
case MESA_FORMAT_A16:
|
||||
case MESA_FORMAT_L16:
|
||||
case MESA_FORMAT_I16:
|
||||
*datatype = GL_UNSIGNED_SHORT;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ typedef enum
|
|||
MESA_FORMAT_L8, /* LLLL LLLL */
|
||||
MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */
|
||||
MESA_FORMAT_I8, /* IIII IIII */
|
||||
MESA_FORMAT_I16, /* IIII IIII IIII IIII */
|
||||
MESA_FORMAT_CI8, /* CCCC CCCC */
|
||||
MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
|
||||
MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
|
||||
|
|
|
|||
|
|
@ -313,6 +313,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
|
|||
fetch_texel_3d_f_i8,
|
||||
store_texel_i8
|
||||
},
|
||||
{
|
||||
MESA_FORMAT_I16,
|
||||
fetch_texel_1d_f_i16,
|
||||
fetch_texel_2d_f_i16,
|
||||
fetch_texel_3d_f_i16,
|
||||
store_texel_i16
|
||||
},
|
||||
{
|
||||
MESA_FORMAT_CI8,
|
||||
fetch_texel_1d_f_ci8,
|
||||
|
|
|
|||
|
|
@ -1244,6 +1244,30 @@ static void store_texel_i8(struct gl_texture_image *texImage,
|
|||
#endif
|
||||
|
||||
|
||||
/* MESA_FORMAT_I16 ***********************************************************/
|
||||
|
||||
/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */
|
||||
static void FETCH(f_i16)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
|
||||
texel[RCOMP] =
|
||||
texel[GCOMP] =
|
||||
texel[BCOMP] =
|
||||
texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
|
||||
}
|
||||
|
||||
#if DIM == 3
|
||||
static void store_texel_i16(struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, const void *texel)
|
||||
{
|
||||
const GLushort *rgba = (const GLushort *) texel;
|
||||
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
|
||||
*dst = rgba[RCOMP];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* MESA_FORMAT_CI8 ***********************************************************/
|
||||
|
||||
/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
|
||||
|
|
|
|||
|
|
@ -137,11 +137,13 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
|
|||
|
||||
case GL_INTENSITY:
|
||||
case GL_INTENSITY4:
|
||||
case GL_INTENSITY12:
|
||||
case GL_INTENSITY16:
|
||||
case GL_INTENSITY8:
|
||||
return MESA_FORMAT_I8;
|
||||
|
||||
case GL_INTENSITY12:
|
||||
case GL_INTENSITY16:
|
||||
return MESA_FORMAT_I16;
|
||||
|
||||
case GL_COLOR_INDEX:
|
||||
case GL_COLOR_INDEX1_EXT:
|
||||
case GL_COLOR_INDEX2_EXT:
|
||||
|
|
|
|||
|
|
@ -2357,7 +2357,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS)
|
|||
}
|
||||
|
||||
|
||||
/* Texstore for R16, A16, L16. */
|
||||
/* Texstore for R16, A16, L16, I16. */
|
||||
static GLboolean
|
||||
_mesa_texstore_unorm16(TEXSTORE_PARAMS)
|
||||
{
|
||||
|
|
@ -2367,7 +2367,8 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS)
|
|||
|
||||
ASSERT(dstFormat == MESA_FORMAT_R16 ||
|
||||
dstFormat == MESA_FORMAT_A16 ||
|
||||
dstFormat == MESA_FORMAT_L16);
|
||||
dstFormat == MESA_FORMAT_L16 ||
|
||||
dstFormat == MESA_FORMAT_I16);
|
||||
ASSERT(texelBytes == 2);
|
||||
|
||||
if (!ctx->_ImageTransferState &&
|
||||
|
|
@ -4053,6 +4054,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
|
|||
{ MESA_FORMAT_L8, _mesa_texstore_a8 },
|
||||
{ MESA_FORMAT_L16, _mesa_texstore_unorm16 },
|
||||
{ MESA_FORMAT_I8, _mesa_texstore_a8 },
|
||||
{ MESA_FORMAT_I16, _mesa_texstore_unorm16 },
|
||||
{ MESA_FORMAT_CI8, _mesa_texstore_ci8 },
|
||||
{ MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr },
|
||||
{ MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue