diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/extensions.c | 3 | ||||
-rw-r--r-- | src/mesa/main/fbobject.c | 38 | ||||
-rw-r--r-- | src/mesa/main/formats.c | 100 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 15 | ||||
-rw-r--r-- | src/mesa/main/image.c | 28 | ||||
-rw-r--r-- | src/mesa/main/macros.h | 3 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 49 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 31 | ||||
-rw-r--r-- | src/mesa/main/version.c | 1 |
10 files changed, 233 insertions, 37 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 7844b5060a1..285e08d7596 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -203,6 +203,7 @@ static const struct extension extension_table[] = { { "GL_EXT_texture", o(EXT_texture), GL, 1996 }, { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GL, 2004 }, { "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL, 2004 }, + { "GL_EXT_texture_snorm", o(EXT_texture_snorm), GL, 2009 }, { "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL, 2004 }, { "GL_EXT_texture_sRGB_decode", o(EXT_texture_sRGB_decode), GL, 2006 }, { "GL_EXT_texture_swizzle", o(EXT_texture_swizzle), GL, 2008 }, @@ -274,7 +275,7 @@ static const struct extension extension_table[] = { { "GL_MESA_pack_invert", o(MESA_pack_invert), GL, 2002 }, { "GL_MESA_resize_buffers", o(MESA_resize_buffers), GL, 1999 }, { "GL_MESA_texture_array", o(MESA_texture_array), GL, 2007 }, - { "GL_MESA_texture_signed_rgba", o(MESA_texture_signed_rgba), GL, 2009 }, + { "GL_MESA_texture_signed_rgba", o(EXT_texture_snorm), GL, 2009 }, { "GL_MESA_window_pos", o(ARB_window_pos), GL, 2000 }, { "GL_MESAX_texture_float", o(ARB_texture_float), GL, 2009 }, { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), GL, 2002 }, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index cc13103de40..4eab3e11911 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1081,7 +1081,6 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_RGB10_A2: case GL_RGBA12: case GL_RGBA16: - case GL_RGBA16_SNORM: case GL_SRGB8_ALPHA8_EXT: return GL_RGBA; case GL_STENCIL_INDEX: @@ -1109,6 +1108,43 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_RG8: case GL_RG16: return ctx->Extensions.ARB_texture_rg ? GL_RG : 0; + /* signed normalized texture formats */ + case GL_RED_SNORM: + case GL_R8_SNORM: + case GL_R16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RED : 0; + case GL_RG_SNORM: + case GL_RG8_SNORM: + case GL_RG16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RG : 0; + case GL_RGB_SNORM: + case GL_RGB8_SNORM: + case GL_RGB16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RGB : 0; + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + case GL_RGBA16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RGBA : 0; + case GL_ALPHA_SNORM: + case GL_ALPHA8_SNORM: + case GL_ALPHA16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + case GL_LUMINANCE16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + case GL_LUMINANCE16_ALPHA16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + case GL_INTENSITY16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; /* XXX add floating point and integer formats eventually */ default: return 0; diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index db10c9b4c2e..e62170b71c1 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -809,8 +809,8 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 1, 1, 1 /* BlockWidth/Height,Bytes */ }, { - MESA_FORMAT_SIGNED_RG88, - "MESA_FORMAT_SIGNED_RG88", + MESA_FORMAT_SIGNED_RG88_REV, + "MESA_FORMAT_SIGNED_RG88_REV", GL_RG, GL_SIGNED_NORMALIZED, 8, 8, 0, 0, @@ -847,8 +847,8 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = /* Signed 16 bits / channel */ { - MESA_FORMAT_SIGNED_R_16, - "MESA_FORMAT_SIGNED_R_16", + MESA_FORMAT_SIGNED_R16, + "MESA_FORMAT_SIGNED_R16", GL_RED, GL_SIGNED_NORMALIZED, 16, 0, 0, 0, @@ -856,8 +856,8 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 1, 1, 2 }, { - MESA_FORMAT_SIGNED_RG_16, - "MESA_FORMAT_SIGNED_RG_16", + MESA_FORMAT_SIGNED_GR1616, + "MESA_FORMAT_SIGNED_GR1616", GL_RG, GL_SIGNED_NORMALIZED, 16, 16, 0, 0, @@ -963,6 +963,80 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 4, 0, 0, 0, 0, 4, 4, 16 /* 16 bytes per 4x4 block */ }, + + /* Signed formats from EXT_texture_snorm that are not in GL3.1 */ + { + MESA_FORMAT_SIGNED_A8, + "MESA_FORMAT_SIGNED_A8", + GL_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 8, + 0, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SIGNED_L8, + "MESA_FORMAT_SIGNED_L8", + GL_LUMINANCE, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 8, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SIGNED_AL88, + "MESA_FORMAT_SIGNED_AL88", + GL_LUMINANCE_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 8, + 8, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_I8, + "MESA_FORMAT_SIGNED_I8", + GL_INTENSITY, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 8, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SIGNED_A16, + "MESA_FORMAT_SIGNED_A16", + GL_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 16, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_L16, + "MESA_FORMAT_SIGNED_L16", + GL_LUMINANCE, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 16, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_AL1616, + "MESA_FORMAT_SIGNED_AL1616", + GL_LUMINANCE_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 16, + 16, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_I16, + "MESA_FORMAT_SIGNED_I16", + GL_INTENSITY, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 16, 0, 0, 0, + 1, 1, 2 + } }; @@ -1530,10 +1604,14 @@ _mesa_format_to_type_and_comps(gl_format format, return; case MESA_FORMAT_SIGNED_R8: + case MESA_FORMAT_SIGNED_A8: + case MESA_FORMAT_SIGNED_L8: + case MESA_FORMAT_SIGNED_I8: *datatype = GL_BYTE; *comps = 1; return; - case MESA_FORMAT_SIGNED_RG88: + case MESA_FORMAT_SIGNED_RG88_REV: + case MESA_FORMAT_SIGNED_AL88: *datatype = GL_BYTE; *comps = 2; return; @@ -1549,11 +1627,15 @@ _mesa_format_to_type_and_comps(gl_format format, *comps = 4; return; - case MESA_FORMAT_SIGNED_R_16: + case MESA_FORMAT_SIGNED_R16: + case MESA_FORMAT_SIGNED_A16: + case MESA_FORMAT_SIGNED_L16: + case MESA_FORMAT_SIGNED_I16: *datatype = GL_SHORT; *comps = 1; return; - case MESA_FORMAT_SIGNED_RG_16: + case MESA_FORMAT_SIGNED_GR1616: + case MESA_FORMAT_SIGNED_AL1616: *datatype = GL_SHORT; *comps = 2; return; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 04a18930b4e..e0c2acbb9e9 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -168,12 +168,12 @@ typedef enum /*@{*/ MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ - MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_SIGNED_RG88_REV, /* GGGG GGGG RRRR RRRR */ MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */ - MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ + MESA_FORMAT_SIGNED_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_SIGNED_GR1616, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ MESA_FORMAT_SIGNED_RGBA_16, /* ... */ MESA_FORMAT_RGBA_16, /* ... */ @@ -193,6 +193,15 @@ typedef enum MESA_FORMAT_SIGNED_LA_LATC2, /*@}*/ + MESA_FORMAT_SIGNED_A8, /* AAAA AAAA */ + MESA_FORMAT_SIGNED_L8, /* LLLL LLLL */ + MESA_FORMAT_SIGNED_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_SIGNED_I8, /* IIII IIII */ + MESA_FORMAT_SIGNED_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_SIGNED_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_SIGNED_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_SIGNED_I16, /* IIII IIII IIII IIII */ + MESA_FORMAT_COUNT } gl_format; diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index bbde3800e8c..28841c25102 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -748,9 +748,6 @@ _mesa_is_color_format(GLenum format) case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: - /* signed, normalized texture formats */ - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: /* generic integer formats */ case GL_RED_INTEGER_EXT: case GL_GREEN_INTEGER_EXT: @@ -799,6 +796,31 @@ _mesa_is_color_format(GLenum format) case GL_INTENSITY8I_EXT: case GL_LUMINANCE8I_EXT: case GL_LUMINANCE_ALPHA8I_EXT: + /* signed, normalized texture formats */ + case GL_RED_SNORM: + case GL_R8_SNORM: + case GL_R16_SNORM: + case GL_RG_SNORM: + case GL_RG8_SNORM: + case GL_RG16_SNORM: + case GL_RGB_SNORM: + case GL_RGB8_SNORM: + case GL_RGB16_SNORM: + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + case GL_RGBA16_SNORM: + case GL_ALPHA_SNORM: + case GL_ALPHA8_SNORM: + case GL_ALPHA16_SNORM: + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + case GL_LUMINANCE16_SNORM: + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + case GL_LUMINANCE16_ALPHA16_SNORM: + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + case GL_INTENSITY16_SNORM: return GL_TRUE; case GL_YCBCR_MESA: /* not considered to be RGB */ /* fall-through */ diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index b2ec0ba9b73..86a58cc6b43 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -58,8 +58,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; #define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F)) /** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */ -#define FLOAT_TO_BYTE_TEX(X) ( (GLint) (127.0F * (X)) ) - +#define FLOAT_TO_BYTE_TEX(X) CLAMP( (GLint) (127.0F * (X)), -128, 127 ) /** Convert GLushort in [0,65535] to GLfloat in [0.0,1.0] */ #define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2e3ea5c0c1c..02676006a9f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2828,6 +2828,7 @@ struct gl_extensions GLboolean EXT_texture_lod_bias; GLboolean EXT_texture_mirror_clamp; GLboolean EXT_texture_shared_exponent; + GLboolean EXT_texture_snorm; GLboolean EXT_texture_sRGB; GLboolean EXT_texture_sRGB_decode; GLboolean EXT_texture_swizzle; @@ -2855,7 +2856,6 @@ struct gl_extensions GLboolean MESA_resize_buffers; GLboolean MESA_ycbcr_texture; GLboolean MESA_texture_array; - GLboolean MESA_texture_signed_rgba; GLboolean NV_blend_square; GLboolean NV_conditional_render; GLboolean NV_fragment_program; diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 5eabf2aa527..8b7b4ff475d 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -389,19 +389,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, } } - if (ctx->Extensions.MESA_texture_signed_rgba) { - switch (internalFormat) { - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: - RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888); - RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV); - break; - default: - ; /* fallthrough */ - } - } - - if (ctx->VersionMajor * 10 + ctx->VersionMinor >= 31) { + if (ctx->Extensions.EXT_texture_snorm) { switch (internalFormat) { case GL_RED_SNORM: case GL_R8_SNORM: @@ -409,7 +397,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, break; case GL_RG_SNORM: case GL_RG8_SNORM: - RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RG88); + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RG88_REV); break; case GL_RGB_SNORM: case GL_RGB8_SNORM: @@ -418,12 +406,29 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, case GL_RGBA_SNORM: case GL_RGBA8_SNORM: RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV); break; + case GL_ALPHA_SNORM: + case GL_ALPHA8_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_A8); + break; + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_L8); + break; + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_AL88); + break; + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_I8); + break; case GL_R16_SNORM: - RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_R_16); + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_R16); break; case GL_RG16_SNORM: - RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RG_16); + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_GR1616); break; case GL_RGB16_SNORM: RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGB_16); @@ -431,6 +436,18 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, case GL_RGBA16_SNORM: RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA_16); break; + case GL_ALPHA16_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_A16); + break; + case GL_LUMINANCE16_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_L16); + break; + case GL_LUMINANCE16_ALPHA16_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_AL1616); + break; + case GL_INTENSITY16_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_I16); + break; default: ; /* fall-through */ } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index c6b8c05b100..86927d3b661 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -311,11 +311,40 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) } } - if (ctx->Extensions.MESA_texture_signed_rgba) { + if (ctx->Extensions.EXT_texture_snorm) { switch (internalFormat) { + case GL_RED_SNORM: + case GL_R8_SNORM: + case GL_R16_SNORM: + return GL_RED; + case GL_RG_SNORM: + case GL_RG8_SNORM: + case GL_RG16_SNORM: + return GL_RG; + case GL_RGB_SNORM: + case GL_RGB8_SNORM: + case GL_RGB16_SNORM: + return GL_RGB; case GL_RGBA_SNORM: case GL_RGBA8_SNORM: + case GL_RGBA16_SNORM: return GL_RGBA; + case GL_ALPHA_SNORM: + case GL_ALPHA8_SNORM: + case GL_ALPHA16_SNORM: + return GL_ALPHA; + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + case GL_LUMINANCE16_SNORM: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + case GL_LUMINANCE16_ALPHA16_SNORM: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + case GL_INTENSITY16_SNORM: + return GL_INTENSITY; default: ; /* fallthrough */ } diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 956c7b90a37..c7a0d69a4f0 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -114,6 +114,7 @@ compute_version(struct gl_context *ctx) ctx->Extensions.ARB_draw_instanced && ctx->Extensions.ARB_texture_buffer_object && ctx->Extensions.ARB_uniform_buffer_object && + ctx->Extensions.EXT_texture_snorm && ctx->Extensions.NV_primitive_restart && ctx->Extensions.NV_texture_rectangle && ctx->Const.MaxVertexTextureImageUnits >= 16); |