diff options
author | marha <marha@users.sourceforge.net> | 2011-04-15 14:48:46 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-04-15 14:48:46 +0000 |
commit | 71372d36e1a3f0230b88808f70d35446fda12260 (patch) | |
tree | 205982f029074be1167820e69891d8332e0a8df2 /mesalib/src/mesa/state_tracker | |
parent | 019fc27ce6dc2a1809107be10d4deb80e0fa436b (diff) | |
download | vcxsrv-71372d36e1a3f0230b88808f70d35446fda12260.tar.gz vcxsrv-71372d36e1a3f0230b88808f70d35446fda12260.tar.bz2 vcxsrv-71372d36e1a3f0230b88808f70d35446fda12260.zip |
xserver xkeyboard-config libX11 mesa git update 15 April 2011
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_readpixels.c | 21 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_texture.c | 7 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 12 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_format.c | 237 |
4 files changed, 275 insertions, 2 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c index 03f58bf0f..fdb7770e4 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c @@ -201,7 +201,8 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb, enum combination { A8R8G8B8_UNORM_TO_RGBA_UBYTE, A8R8G8B8_UNORM_TO_RGB_UBYTE, - A8R8G8B8_UNORM_TO_BGRA_UINT + A8R8G8B8_UNORM_TO_BGRA_UINT, + A8R8G8B8_UNORM_TO_RGBA_UINT } combo; if (ctx->_ImageTransferState) @@ -219,6 +220,10 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb, format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) { combo = A8R8G8B8_UNORM_TO_BGRA_UINT; } + else if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM && + format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8) { + combo = A8R8G8B8_UNORM_TO_RGBA_UINT; + } else { return GL_FALSE; } @@ -305,6 +310,20 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb, y += dy; } break; + case A8R8G8B8_UNORM_TO_RGBA_UINT: + for (row = 0; row < height; row++) { + const GLubyte *src = map + y * trans->stride; + for (col = 0; col < width; col++) { + GLuint pixel = ((GLuint *) src)[col]; + dst[col*4+0] = (pixel >> 24) & 0xff; + dst[col*4+1] = (pixel >> 0) & 0xff; + dst[col*4+2] = (pixel >> 8) & 0xff; + dst[col*4+3] = (pixel >> 16) & 0xff; + } + dst += dstStride; + y += dy; + } + break; default: ; /* nothing */ } diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 914c06b70..43c24ae95 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -600,7 +600,12 @@ st_TexImage(struct gl_context * ctx, * memory or malloc space for it. */ if (stImage->pt) { - /* Store the image in the gallium texture memory buffer */ + if (!pixels) { + /* We've allocated texture resource, but have no pixel data - all done. */ + goto done; + } + + /* Store the image in the gallium transfer object */ if (format == GL_DEPTH_COMPONENT && util_format_is_depth_and_stencil(stImage->pt->format)) transfer_usage = PIPE_TRANSFER_READ_WRITE; diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 9bc9d7a10..bdc08949d 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -382,6 +382,18 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } + /* float support - assume nothing exclusively supports 64-bit floats */ + if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW | + PIPE_BIND_RENDER_TARGET) && + screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW | + PIPE_BIND_RENDER_TARGET)) { + ctx->Extensions.ARB_texture_float = GL_TRUE; + } + /* sRGB support */ if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, PIPE_TEXTURE_2D, 0, diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 957a06c08..8e50dbda6 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -214,6 +214,39 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_SARGB8: return PIPE_FORMAT_B8G8R8A8_SRGB; #endif + case MESA_FORMAT_RGBA_FLOAT32: + return PIPE_FORMAT_R32G32B32A32_FLOAT; + case MESA_FORMAT_RGBA_FLOAT16: + return PIPE_FORMAT_R16G16B16A16_FLOAT; + case MESA_FORMAT_RGB_FLOAT32: + return PIPE_FORMAT_R32G32B32_FLOAT; + case MESA_FORMAT_RGB_FLOAT16: + return PIPE_FORMAT_R16G16B16_FLOAT; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: + return PIPE_FORMAT_L32A32_FLOAT; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: + return PIPE_FORMAT_L16A16_FLOAT; + case MESA_FORMAT_LUMINANCE_FLOAT32: + return PIPE_FORMAT_L32_FLOAT; + case MESA_FORMAT_LUMINANCE_FLOAT16: + return PIPE_FORMAT_L16_FLOAT; + case MESA_FORMAT_ALPHA_FLOAT32: + return PIPE_FORMAT_A32_FLOAT; + case MESA_FORMAT_ALPHA_FLOAT16: + return PIPE_FORMAT_A16_FLOAT; + case MESA_FORMAT_INTENSITY_FLOAT32: + return PIPE_FORMAT_I32_FLOAT; + case MESA_FORMAT_INTENSITY_FLOAT16: + return PIPE_FORMAT_I16_FLOAT; + case MESA_FORMAT_R_FLOAT32: + return PIPE_FORMAT_R32_FLOAT; + case MESA_FORMAT_R_FLOAT16: + return PIPE_FORMAT_R16_FLOAT; + case MESA_FORMAT_RG_FLOAT32: + return PIPE_FORMAT_R32G32_FLOAT; + case MESA_FORMAT_RG_FLOAT16: + return PIPE_FORMAT_R16G16_FLOAT; + case MESA_FORMAT_R8: return PIPE_FORMAT_R8_UNORM; case MESA_FORMAT_R16: @@ -403,6 +436,38 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_B8G8R8A8_SRGB: return MESA_FORMAT_SARGB8; #endif + case PIPE_FORMAT_R32G32B32A32_FLOAT: + return MESA_FORMAT_RGBA_FLOAT32; + case PIPE_FORMAT_R16G16B16A16_FLOAT: + return MESA_FORMAT_RGBA_FLOAT16; + case PIPE_FORMAT_R32G32B32_FLOAT: + return MESA_FORMAT_RGB_FLOAT32; + case PIPE_FORMAT_R16G16B16_FLOAT: + return MESA_FORMAT_RGB_FLOAT16; + case PIPE_FORMAT_L32A32_FLOAT: + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32; + case PIPE_FORMAT_L16A16_FLOAT: + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16; + case PIPE_FORMAT_L32_FLOAT: + return MESA_FORMAT_LUMINANCE_FLOAT32; + case PIPE_FORMAT_L16_FLOAT: + return MESA_FORMAT_LUMINANCE_FLOAT16; + case PIPE_FORMAT_A32_FLOAT: + return MESA_FORMAT_ALPHA_FLOAT32; + case PIPE_FORMAT_A16_FLOAT: + return MESA_FORMAT_ALPHA_FLOAT16; + case PIPE_FORMAT_I32_FLOAT: + return MESA_FORMAT_INTENSITY_FLOAT32; + case PIPE_FORMAT_I16_FLOAT: + return MESA_FORMAT_INTENSITY_FLOAT16; + case PIPE_FORMAT_R32_FLOAT: + return MESA_FORMAT_R_FLOAT32; + case PIPE_FORMAT_R16_FLOAT: + return MESA_FORMAT_R_FLOAT16; + case PIPE_FORMAT_R32G32_FLOAT: + return MESA_FORMAT_RG_FLOAT32; + case PIPE_FORMAT_R16G16_FLOAT: + return MESA_FORMAT_RG_FLOAT16; case PIPE_FORMAT_R8_UNORM: return MESA_FORMAT_R8; @@ -887,6 +952,178 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_L8_SRGB; return default_srgba_format( screen, target, sample_count, bindings); + /* prefer formats in order of data size, choosing 16-bit ones if equal sized */ + case GL_RGBA16F_ARB: + case GL_RGB16F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_LUMINANCE_ALPHA16F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_ALPHA16F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_A16_FLOAT, + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_A32_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_INTENSITY16F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_I16_FLOAT, + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_I32_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_LUMINANCE16F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L16_FLOAT, + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_L32_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_R16F: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R16_FLOAT, + PIPE_FORMAT_R16G16_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_R32G32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_RG16F: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R16G16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_R32G32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + + /* try a 32-bit format if available, otherwise fallback to a 16-bit one */ + case GL_RGBA32F_ARB: + case GL_RGB32F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_LUMINANCE_ALPHA32F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_ALPHA32F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_A32_FLOAT, + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_A16_FLOAT, + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_INTENSITY32F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_I32_FLOAT, + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_I16_FLOAT, + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_LUMINANCE32F_ARB: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_L32_FLOAT, + PIPE_FORMAT_L32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_L16_FLOAT, + PIPE_FORMAT_L16A16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_R32F: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32G32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_R16_FLOAT, + PIPE_FORMAT_R16G16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_RG32F: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_R32G32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_R16G16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings); + } + case GL_RED: case GL_R8: if (screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, target, |