aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_flush.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_syncobj.c122
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_syncobj.h38
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c25
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c54
-rw-r--r--mesalib/src/mesa/state_tracker/st_gen_mipmap.c10
8 files changed, 247 insertions, 13 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..01496ed07 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_flush.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c
@@ -103,7 +103,8 @@ void st_finish( struct st_context *st )
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_finish(st->pipe->screen, fence, 0,
+ PIPE_TIMEOUT_INFINITE);
st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL);
}
}
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 8f3a7415d..c1b4cde77 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 12142b84e..2f4027bc4 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 511a252f0..32cbcaec1 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 1adfdf72c..5ac4b9f25 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 7a61998e2..34a2e9ebd 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 {