From: Marek Olšák Date: Mon, 14 Mar 2011 09:04:36 +0000 (+0100) Subject: gallium: add EXT_texture_snorm support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2af1da15468d06d3ce9d89bcc706276ecc66f761;p=mesa.git gallium: add EXT_texture_snorm support --- diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 6f5cc618ffc..771bd49412d 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -88,6 +88,14 @@ PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, r PIPE_FORMAT_A16_UNORM , plain, 1, 1, un16, , , , 000x, rgb PIPE_FORMAT_I16_UNORM , plain, 1, 1, un16, , , , xxxx, rgb PIPE_FORMAT_L16A16_UNORM , plain, 1, 1, un16, un16, , , xxxy, rgb +PIPE_FORMAT_A8_SNORM , plain, 1, 1, sn8 , , , , 000x, rgb +PIPE_FORMAT_L8_SNORM , plain, 1, 1, sn8 , , , , xxx1, rgb +PIPE_FORMAT_L8A8_SNORM , plain, 1, 1, sn8 , sn8 , , , xxxy, rgb +PIPE_FORMAT_I8_SNORM , plain, 1, 1, sn8 , , , , xxxx, rgb +PIPE_FORMAT_A16_SNORM , plain, 1, 1, sn16, , , , 000x, rgb +PIPE_FORMAT_L16_SNORM , plain, 1, 1, sn16, , , , xxx1, rgb +PIPE_FORMAT_L16A16_SNORM , plain, 1, 1, sn16, sn16, , , xxxy, rgb +PIPE_FORMAT_I16_SNORM , plain, 1, 1, sn16, , , , xxxx, rgb # SRGB formats PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index d53af598e75..3ea9a3999d1 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -211,6 +211,15 @@ enum pipe_format { PIPE_FORMAT_LATC2_UNORM = 145, PIPE_FORMAT_LATC2_SNORM = 146, + PIPE_FORMAT_A8_SNORM = 147, + PIPE_FORMAT_L8_SNORM = 148, + PIPE_FORMAT_L8A8_SNORM = 149, + PIPE_FORMAT_I8_SNORM = 150, + PIPE_FORMAT_A16_SNORM = 151, + PIPE_FORMAT_L16_SNORM = 152, + PIPE_FORMAT_L16A16_SNORM = 153, + PIPE_FORMAT_I16_SNORM = 154, + PIPE_FORMAT_COUNT }; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 89bb03046c1..ba1a0af0628 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -453,6 +453,12 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE; } + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW)) { + ctx->Extensions.EXT_texture_snorm = GL_TRUE; + } + /* ycbcr support */ if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, PIPE_TEXTURE_2D, 0, diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 03655ee0483..957a06c0880 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -259,6 +259,39 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_SIGNED_LA_LATC2: return PIPE_FORMAT_LATC2_SNORM; + /* signed normalized formats */ + case MESA_FORMAT_SIGNED_R8: + return PIPE_FORMAT_R8_SNORM; + case MESA_FORMAT_SIGNED_RG88_REV: + return PIPE_FORMAT_R8G8_SNORM; + case MESA_FORMAT_SIGNED_RGBA8888_REV: + return PIPE_FORMAT_R8G8B8A8_SNORM; + + case MESA_FORMAT_SIGNED_A8: + return PIPE_FORMAT_A8_SNORM; + case MESA_FORMAT_SIGNED_L8: + return PIPE_FORMAT_L8_SNORM; + case MESA_FORMAT_SIGNED_AL88: + return PIPE_FORMAT_L8A8_SNORM; + case MESA_FORMAT_SIGNED_I8: + return PIPE_FORMAT_I8_SNORM; + + case MESA_FORMAT_SIGNED_R16: + return PIPE_FORMAT_R16_SNORM; + case MESA_FORMAT_SIGNED_GR1616: + return PIPE_FORMAT_R16G16_SNORM; + case MESA_FORMAT_SIGNED_RGBA_16: + return PIPE_FORMAT_R16G16B16A16_SNORM; + + case MESA_FORMAT_SIGNED_A16: + return PIPE_FORMAT_A16_SNORM; + case MESA_FORMAT_SIGNED_L16: + return PIPE_FORMAT_L16_SNORM; + case MESA_FORMAT_SIGNED_AL1616: + return PIPE_FORMAT_L16A16_SNORM; + case MESA_FORMAT_SIGNED_I16: + return PIPE_FORMAT_I16_SNORM; + default: assert(0); return PIPE_FORMAT_NONE; @@ -318,8 +351,6 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_R16G16B16A16_UNORM: return MESA_FORMAT_RGBA_16; - case PIPE_FORMAT_R16G16B16A16_SNORM: - return MESA_FORMAT_SIGNED_RGBA_16; case PIPE_FORMAT_Z16_UNORM: return MESA_FORMAT_Z16; @@ -416,6 +447,39 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_LATC2_SNORM: return MESA_FORMAT_SIGNED_LA_LATC2; + /* signed normalized formats */ + case PIPE_FORMAT_R8_SNORM: + return MESA_FORMAT_SIGNED_R8; + case PIPE_FORMAT_R8G8_SNORM: + return MESA_FORMAT_SIGNED_RG88_REV; + case PIPE_FORMAT_R8G8B8A8_SNORM: + return MESA_FORMAT_SIGNED_RGBA8888_REV; + + case PIPE_FORMAT_A8_SNORM: + return MESA_FORMAT_SIGNED_A8; + case PIPE_FORMAT_L8_SNORM: + return MESA_FORMAT_SIGNED_L8; + case PIPE_FORMAT_L8A8_SNORM: + return MESA_FORMAT_SIGNED_AL88; + case PIPE_FORMAT_I8_SNORM: + return MESA_FORMAT_SIGNED_I8; + + case PIPE_FORMAT_R16_SNORM: + return MESA_FORMAT_SIGNED_R16; + case PIPE_FORMAT_R16G16_SNORM: + return MESA_FORMAT_SIGNED_GR1616; + case PIPE_FORMAT_R16G16B16A16_SNORM: + return MESA_FORMAT_SIGNED_RGBA_16; + + case PIPE_FORMAT_A16_SNORM: + return MESA_FORMAT_SIGNED_A16; + case PIPE_FORMAT_L16_SNORM: + return MESA_FORMAT_SIGNED_L16; + case PIPE_FORMAT_L16A16_SNORM: + return MESA_FORMAT_SIGNED_AL1616; + case PIPE_FORMAT_I16_SNORM: + return MESA_FORMAT_SIGNED_I16; + default: assert(0); return MESA_FORMAT_NONE; @@ -999,6 +1063,170 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_R32G32B32A32_USCALED; return PIPE_FORMAT_NONE; + /* signed normalized formats */ + case GL_RED_SNORM: + case GL_R8_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R8_SNORM, + PIPE_FORMAT_R8G8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_R16_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R16_SNORM, + PIPE_FORMAT_R16G16_SNORM, + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_R8_SNORM, + PIPE_FORMAT_R8G8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_RG_SNORM: + case GL_RG8_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R8G8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_RG16_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R16G16_SNORM, + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_R8G8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_RGB_SNORM: + case GL_RGB8_SNORM: + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SNORM, + target, + sample_count, bindings)) + return PIPE_FORMAT_R8G8B8A8_SNORM; + return PIPE_FORMAT_NONE; + + case GL_RGB16_SNORM: + case GL_RGBA16_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + + case GL_ALPHA_SNORM: + case GL_ALPHA8_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_A8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_ALPHA16_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_A16_SNORM, + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_A8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_LUMINANCE16_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L16_SNORM, + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_L8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L8A8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_LUMINANCE16_ALPHA16_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L16A16_SNORM, + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_L8A8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_I8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + case GL_INTENSITY16_SNORM: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_I16_SNORM, + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_I8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + default: return PIPE_FORMAT_NONE; }