diff options
author | marha <marha@users.sourceforge.net> | 2011-03-10 09:49:29 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-03-10 09:49:29 +0000 |
commit | f81bb3160c5f39d8f7ad329e99865af88f02b96a (patch) | |
tree | e12e90b1707bed3f4fdd6a3901f4cbcbe76d0b34 /mesalib/src/mesa/state_tracker | |
parent | 8c74e7257ed453143c53086f884f6c6ff585379a (diff) | |
download | vcxsrv-f81bb3160c5f39d8f7ad329e99865af88f02b96a.tar.gz vcxsrv-f81bb3160c5f39d8f7ad329e99865af88f02b96a.tar.bz2 vcxsrv-f81bb3160c5f39d8f7ad329e99865af88f02b96a.zip |
xserver mesa git update 10 Mar 2011
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_flush.c | 329 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_syncobj.c | 122 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_syncobj.h | 38 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_context.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_draw.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 25 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_format.c | 54 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_gen_mipmap.c | 10 |
8 files changed, 410 insertions, 176 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c index 31189f360..35ab00f6d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_flush.c +++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c @@ -1,164 +1,165 @@ -/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Brian Paul
- */
-
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/context.h"
-#include "st_context.h"
-#include "st_cb_bitmap.h"
-#include "st_cb_flush.h"
-#include "st_cb_clear.h"
-#include "st_cb_fbo.h"
-#include "st_manager.h"
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_screen.h"
-#include "util/u_gen_mipmap.h"
-#include "util/u_blit.h"
-
-
-/** Check if we have a front color buffer and if it's been drawn to. */
-static INLINE GLboolean
-is_front_buffer_dirty(struct st_context *st)
-{
- struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- struct st_renderbuffer *strb
- = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
- return strb && strb->defined;
-}
-
-
-/**
- * Tell the screen to display the front color buffer on-screen.
- */
-static void
-display_front_buffer(struct st_context *st)
-{
- struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- struct st_renderbuffer *strb
- = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
-
- if (strb) {
- /* Hook for copying "fake" frontbuffer if necessary:
- */
- st_manager_flush_frontbuffer(st);
- }
-}
-
-
-void st_flush( struct st_context *st, uint pipeFlushFlags,
- struct pipe_fence_handle **fence )
-{
- FLUSH_CURRENT(st->ctx, 0);
-
- /* Release any vertex buffers that might potentially be accessed in
- * successive frames:
- */
- st_flush_bitmap(st);
- st_flush_clear(st);
- util_blit_flush(st->blit);
- util_gen_mipmap_flush(st->gen_mipmap);
-
- st->pipe->flush( st->pipe, pipeFlushFlags, fence );
-}
-
-
-/**
- * Flush, and wait for completion.
- */
-void st_finish( struct st_context *st )
-{
- struct pipe_fence_handle *fence = NULL;
-
- st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
-
- if(fence) {
- st->pipe->screen->fence_finish(st->pipe->screen, fence, 0);
- st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL);
- }
-}
-
-
-
-/**
- * Called via ctx->Driver.Flush()
- */
-static void st_glFlush(struct gl_context *ctx)
-{
- struct st_context *st = st_context(ctx);
-
- /* Don't call st_finish() here. It is not the state tracker's
- * responsibilty to inject sleeps in the hope of avoiding buffer
- * synchronization issues. Calling finish() here will just hide
- * problems that need to be fixed elsewhere.
- */
- st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
-
- if (is_front_buffer_dirty(st)) {
- display_front_buffer(st);
- }
-}
-
-
-/**
- * Called via ctx->Driver.Finish()
- */
-static void st_glFinish(struct gl_context *ctx)
-{
- struct st_context *st = st_context(ctx);
-
- st_finish(st);
-
- if (is_front_buffer_dirty(st)) {
- display_front_buffer(st);
- }
-}
-
-
-void st_init_flush_functions(struct dd_function_table *functions)
-{
- functions->Flush = st_glFlush;
- functions->Finish = st_glFinish;
-
- /* Windows opengl32.dll calls glFinish prior to every swapbuffers.
- * This is unnecessary and degrades performance. Luckily we have some
- * scope to work around this, as the externally-visible behaviour of
- * Finish() is identical to Flush() in all cases - no differences in
- * rendering or ReadPixels are visible if we opt not to wait here.
- *
- * Only set this up on windows to avoid suprise elsewhere.
- */
-#ifdef PIPE_OS_WINDOWS
- functions->Finish = st_glFlush;
-#endif
-}
+/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + /* + * Authors: + * Keith Whitwell <keith@tungstengraphics.com> + * Brian Paul + */ + +#include "main/glheader.h" +#include "main/macros.h" +#include "main/context.h" +#include "st_context.h" +#include "st_cb_bitmap.h" +#include "st_cb_flush.h" +#include "st_cb_clear.h" +#include "st_cb_fbo.h" +#include "st_manager.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" +#include "util/u_gen_mipmap.h" +#include "util/u_blit.h" + + +/** Check if we have a front color buffer and if it's been drawn to. */ +static INLINE GLboolean +is_front_buffer_dirty(struct st_context *st) +{ + struct gl_framebuffer *fb = st->ctx->DrawBuffer; + struct st_renderbuffer *strb + = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + return strb && strb->defined; +} + + +/** + * Tell the screen to display the front color buffer on-screen. + */ +static void +display_front_buffer(struct st_context *st) +{ + struct gl_framebuffer *fb = st->ctx->DrawBuffer; + struct st_renderbuffer *strb + = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + + if (strb) { + /* Hook for copying "fake" frontbuffer if necessary: + */ + st_manager_flush_frontbuffer(st); + } +} + + +void st_flush( struct st_context *st, uint pipeFlushFlags, + struct pipe_fence_handle **fence ) +{ + FLUSH_CURRENT(st->ctx, 0); + + /* Release any vertex buffers that might potentially be accessed in + * successive frames: + */ + st_flush_bitmap(st); + st_flush_clear(st); + util_blit_flush(st->blit); + util_gen_mipmap_flush(st->gen_mipmap); + + st->pipe->flush( st->pipe, pipeFlushFlags, fence ); +} + + +/** + * Flush, and wait for completion. + */ +void st_finish( struct st_context *st ) +{ + struct pipe_fence_handle *fence = NULL; + + st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence); + + if(fence) { + st->pipe->screen->fence_finish(st->pipe->screen, fence, 0, + PIPE_TIMEOUT_INFINITE); + st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL); + } +} + + + +/** + * Called via ctx->Driver.Flush() + */ +static void st_glFlush(struct gl_context *ctx) +{ + struct st_context *st = st_context(ctx); + + /* Don't call st_finish() here. It is not the state tracker's + * responsibilty to inject sleeps in the hope of avoiding buffer + * synchronization issues. Calling finish() here will just hide + * problems that need to be fixed elsewhere. + */ + st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + + if (is_front_buffer_dirty(st)) { + display_front_buffer(st); + } +} + + +/** + * Called via ctx->Driver.Finish() + */ +static void st_glFinish(struct gl_context *ctx) +{ + struct st_context *st = st_context(ctx); + + st_finish(st); + + if (is_front_buffer_dirty(st)) { + display_front_buffer(st); + } +} + + +void st_init_flush_functions(struct dd_function_table *functions) +{ + functions->Flush = st_glFlush; + functions->Finish = st_glFinish; + + /* Windows opengl32.dll calls glFinish prior to every swapbuffers. + * This is unnecessary and degrades performance. Luckily we have some + * scope to work around this, as the externally-visible behaviour of + * Finish() is identical to Flush() in all cases - no differences in + * rendering or ReadPixels are visible if we opt not to wait here. + * + * Only set this up on windows to avoid suprise elsewhere. + */ +#ifdef PIPE_OS_WINDOWS + functions->Finish = st_glFlush; +#endif +} diff --git a/mesalib/src/mesa/state_tracker/st_cb_syncobj.c b/mesalib/src/mesa/state_tracker/st_cb_syncobj.c new file mode 100644 index 000000000..85aad08cc --- /dev/null +++ b/mesalib/src/mesa/state_tracker/st_cb_syncobj.c @@ -0,0 +1,122 @@ +/************************************************************************** + * + * Copyright 2011 Marek Olšák <maraeo@gmail.com> + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + /* + * Authors: + * Marek Olšák <maraeo@gmail.com> + */ + +#include "main/glheader.h" +#include "main/macros.h" +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "st_context.h" +#include "st_cb_syncobj.h" + +struct st_sync_object { + struct gl_sync_object b; + + struct pipe_fence_handle *fence; +}; + + +static struct gl_sync_object * st_new_sync_object(struct gl_context *ctx, + GLenum type) +{ + if (type == GL_SYNC_FENCE) + return (struct gl_sync_object*)CALLOC_STRUCT(st_sync_object); + else + return NULL; +} + +static void st_delete_sync_object(struct gl_context *ctx, + struct gl_sync_object *obj) +{ + struct pipe_screen *screen = st_context(ctx)->pipe->screen; + struct st_sync_object *so = (struct st_sync_object*)obj; + + screen->fence_reference(screen, &so->fence, NULL); + FREE(so); +} + +static void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj, + GLenum condition, GLbitfield flags) +{ + struct pipe_context *pipe = st_context(ctx)->pipe; + struct st_sync_object *so = (struct st_sync_object*)obj; + + assert(condition == GL_SYNC_GPU_COMMANDS_COMPLETE && flags == 0); + assert(so->fence == NULL); + + pipe->flush(pipe, 0, &so->fence); +} + +static void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj) +{ + struct pipe_screen *screen = st_context(ctx)->pipe->screen; + struct st_sync_object *so = (struct st_sync_object*)obj; + + if (so->fence && screen->fence_signalled(screen, so->fence, 0) == 0) { + screen->fence_reference(screen, &so->fence, NULL); + so->b.StatusFlag = GL_TRUE; + } +} + +static void st_client_wait_sync(struct gl_context *ctx, + struct gl_sync_object *obj, + GLbitfield flags, GLuint64 timeout) +{ + struct pipe_screen *screen = st_context(ctx)->pipe->screen; + struct st_sync_object *so = (struct st_sync_object*)obj; + + /* We don't care about GL_SYNC_FLUSH_COMMANDS_BIT, because flush is + * already called when creating a fence. */ + + if (so->fence && + screen->fence_finish(screen, so->fence, 0, timeout) == 0) { + screen->fence_reference(screen, &so->fence, NULL); + so->b.StatusFlag = GL_TRUE; + } +} + +static void st_server_wait_sync(struct gl_context *ctx, + struct gl_sync_object *obj, + GLbitfield flags, GLuint64 timeout) +{ + /* NO-OP. + * Neither Gallium nor DRM interfaces support blocking on the GPU. */ +} + +void st_init_syncobj_functions(struct dd_function_table *functions) +{ + functions->NewSyncObject = st_new_sync_object; + functions->FenceSync = st_fence_sync; + functions->DeleteSyncObject = st_delete_sync_object; + functions->CheckSync = st_check_sync; + functions->ClientWaitSync = st_client_wait_sync; + functions->ServerWaitSync = st_server_wait_sync; +} diff --git a/mesalib/src/mesa/state_tracker/st_cb_syncobj.h b/mesalib/src/mesa/state_tracker/st_cb_syncobj.h new file mode 100644 index 000000000..c25468478 --- /dev/null +++ b/mesalib/src/mesa/state_tracker/st_cb_syncobj.h @@ -0,0 +1,38 @@ +/************************************************************************** + * + * Copyright 2011 Marek Olšák <maraeo@gmail.com> + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef ST_CB_SYNCOBJ_H +#define ST_CB_SYNCOBJ_H + + +struct dd_function_table; + +extern void +st_init_syncobj_functions(struct dd_function_table *functions); + + +#endif /* ST_CB_SYNCOBJ_H */ diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 7a19f35bb..60972e07d 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -51,6 +51,7 @@ #include "st_cb_texture.h" #include "st_cb_xformfb.h" #include "st_cb_flush.h" +#include "st_cb_syncobj.h" #include "st_cb_strings.h" #include "st_cb_viewport.h" #include "st_atom.h" @@ -292,6 +293,7 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_viewport_functions(functions); st_init_xformfb_functions(functions); + st_init_syncobj_functions(functions); functions->UpdateState = st_invalidate_state; } diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index d6e67b7fb..40afa4362 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -429,7 +429,7 @@ setup_non_interleaved_attribs(struct gl_context *ctx, vbuffer[attr].buffer_offset = 0; /* Track user vertex buffers. */ - pipe_resource_reference(&st->user_vb[attr], vbuffer->buffer); + pipe_resource_reference(&st->user_vb[attr], vbuffer[attr].buffer); st->user_vb_stride[attr] = stride; st->num_user_vbs = MAX2(st->num_user_vbs, attr+1); } @@ -632,10 +632,8 @@ st_draw_vbo(struct gl_context *ctx, struct pipe_index_buffer ibuffer; struct pipe_draw_info info; unsigned i, num_instances = 1; - GLboolean new_array = GL_TRUE; - /* Fix this (Bug 34378): GLboolean new_array = - st->dirty.st && (st->dirty.mesa & (_NEW_ARRAY | _NEW_PROGRAM)) != 0;*/ + st->dirty.st && (st->dirty.mesa & (_NEW_ARRAY | _NEW_PROGRAM)) != 0; /* Mesa core state should have been validated already */ assert(ctx->NewState == 0x0); diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 6bbf68acc..aaa1658f4 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -432,6 +432,27 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE; } + if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_LATC1_SNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_LATC2_SNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.EXT_texture_compression_latc = GL_TRUE; + } + + if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE; + } + /* ycbcr support */ if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, PIPE_TEXTURE_2D, 0, @@ -497,4 +518,8 @@ void st_init_extensions(struct st_context *st) if (screen->get_param(screen, PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR)) { ctx->Extensions.ARB_instanced_arrays = GL_TRUE; } + + if (screen->fence_finish) { + ctx->Extensions.ARB_sync = GL_TRUE; + } } diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 22a1450cf..6b89bae7d 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -249,6 +249,16 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) return PIPE_FORMAT_RGTC2_UNORM; case MESA_FORMAT_SIGNED_RG_RGTC2: return PIPE_FORMAT_RGTC2_SNORM; + + case MESA_FORMAT_L_LATC1: + return PIPE_FORMAT_LATC1_UNORM; + case MESA_FORMAT_SIGNED_L_LATC1: + return PIPE_FORMAT_LATC1_SNORM; + case MESA_FORMAT_LA_LATC2: + return PIPE_FORMAT_LATC2_UNORM; + case MESA_FORMAT_SIGNED_LA_LATC2: + return PIPE_FORMAT_LATC2_SNORM; + default: assert(0); return PIPE_FORMAT_NONE; @@ -397,6 +407,15 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_RGTC2_SNORM: return MESA_FORMAT_SIGNED_RG_RGTC2; + case PIPE_FORMAT_LATC1_UNORM: + return MESA_FORMAT_L_LATC1; + case PIPE_FORMAT_LATC1_SNORM: + return MESA_FORMAT_SIGNED_L_LATC1; + case PIPE_FORMAT_LATC2_UNORM: + return MESA_FORMAT_LA_LATC2; + case PIPE_FORMAT_LATC2_SNORM: + return MESA_FORMAT_SIGNED_LA_LATC2; + default: assert(0); return MESA_FORMAT_NONE; @@ -612,7 +631,6 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: - case GL_COMPRESSED_LUMINANCE: if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, sample_count, bindings, geom_flags )) return PIPE_FORMAT_L8_UNORM; @@ -630,7 +648,6 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE_ALPHA: case GL_LUMINANCE6_ALPHA2: case GL_LUMINANCE8_ALPHA8: - case GL_COMPRESSED_LUMINANCE_ALPHA: if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, sample_count, bindings, geom_flags )) return PIPE_FORMAT_L8A8_UNORM; @@ -901,6 +918,39 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_RGTC2_SNORM; return PIPE_FORMAT_NONE; + case GL_COMPRESSED_LUMINANCE: + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_LATC1_UNORM; + if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_L8_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_SNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_LATC1_SNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_LUMINANCE_ALPHA: + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: + if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_LATC2_UNORM; + if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_L8A8_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_SNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_LATC2_SNORM; + return PIPE_FORMAT_NONE; + /* signed/unsigned integer formats. * XXX Mesa only has formats for RGBA signed/unsigned integer formats. * If/when new formats are added this code should be updated. diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c index a12a32e11..899161e78 100644 --- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c +++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c @@ -204,12 +204,10 @@ fallback_generate_mipmap(struct gl_context *ctx, GLenum target, _mesa_is_format_compressed(texObj->Image[face][baseLevel]->TexFormat); if (compressed) { - if (texObj->Image[face][baseLevel]->TexFormat == MESA_FORMAT_SIGNED_RED_RGTC1 || - texObj->Image[face][baseLevel]->TexFormat == MESA_FORMAT_SIGNED_RG_RGTC2) - datatype = GL_FLOAT; - else - datatype = GL_UNSIGNED_BYTE; - + GLenum type = + _mesa_get_format_datatype(texObj->Image[face][baseLevel]->TexFormat); + + datatype = type == GL_UNSIGNED_NORMALIZED ? GL_UNSIGNED_BYTE : GL_FLOAT; comps = 4; } else { |