summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-20 11:20:25 -0700
committerBrian <[email protected]>2008-02-20 11:20:25 -0700
commit58edb0683db45c449b219988a8715cf8fd69e42d (patch)
tree1797c58be2dfa6768673e8542a754797d37065e4
parent22a0b85eaebf767f5b03bf899596e09f5cc03876 (diff)
gallium: state tracker didn't always notify drivers of texobj data changes
Calling glTexSubImage() or glTexImage() to replace texture data didn't reliably cause pipe->set_sampler_texture() to get called so drivers didn't always get notified of new texture data. The st_texture_object->pt pointer doesn't always indicate changed data so added a dirtyData field.
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c18
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c3
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c1
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c42
-rw-r--r--src/mesa/state_tracker/st_cb_texture.h32
-rw-r--r--src/mesa/state_tracker/st_context.h22
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c4
-rw-r--r--src/mesa/state_tracker/st_texture.h64
8 files changed, 115 insertions, 71 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 2a836d630b2..9fead7e314d 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -34,6 +34,7 @@
#include "st_context.h"
#include "st_atom.h"
+#include "st_texture.h"
#include "st_cb_texture.h"
#include "pipe/p_context.h"
@@ -53,27 +54,26 @@ update_textures(struct st_context *st)
for (unit = 0; unit < st->ctx->Const.MaxTextureCoordUnits; unit++) {
const GLuint su = fprog->Base.SamplerUnits[unit];
struct gl_texture_object *texObj = st->ctx->Texture.Unit[su]._Current;
- struct pipe_texture *pt;
+ struct st_texture_object *stObj = st_texture_object(texObj);
if (texObj) {
GLboolean flush, retval;
retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
/* XXX retval indicates whether there's a texture border */
-
- pt = st_get_texobj_texture(texObj);
- }
- else {
- pt = NULL;
}
/* XXX: need to ensure that textures are unbound/removed from
* this table before being deleted, otherwise the pointer
* comparison below could fail.
*/
- if (st->state.sampler_texture[unit] != pt) {
- st->state.sampler_texture[unit] = pt;
- st->pipe->set_sampler_texture(st->pipe, unit, pt);
+ if (st->state.sampler_texture[unit] != stObj ||
+ (stObj && stObj->dirtyData)) {
+ struct pipe_texture *pt = st_get_stobj_texture(stObj);
+ st->state.sampler_texture[unit] = stObj;
+ st->pipe->set_sampler_texture(st->pipe, unit, pt);
+ if (stObj)
+ stObj->dirtyData = GL_FALSE;
}
}
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index e2d4e06da19..585cae37436 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -726,7 +726,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data);
- pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]);
+ pipe->set_sampler_texture(pipe, unit,
+ st_get_stobj_texture(ctx->st->state.sampler_texture[unit]));
pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 43416232670..781425b5469 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -48,6 +48,7 @@
#include "st_cb_texture.h"
#include "st_format.h"
#include "st_public.h"
+#include "st_texture.h"
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 03dbb30b0fe..7226b0dd98d 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -53,33 +53,6 @@
#define DBG if (0) printf
-struct st_texture_object
-{
- struct gl_texture_object base; /* The "parent" object */
-
- /* The texture must include at levels [0..lastLevel] once validated:
- */
- GLuint lastLevel;
-
- /* On validation any active images held in main memory or in other
- * textures will be copied to this texture and the old storage freed.
- */
- struct pipe_texture *pt;
-
- GLboolean imageOverride;
- GLint depthOverride;
- GLuint pitchOverride;
-};
-
-
-
-static INLINE struct st_texture_object *
-st_texture_object(struct gl_texture_object *obj)
-{
- return (struct st_texture_object *) obj;
-}
-
-
static INLINE struct st_texture_image *
st_texture_image(struct gl_texture_image *img)
{
@@ -87,14 +60,6 @@ st_texture_image(struct gl_texture_image *img)
}
-struct pipe_texture *
-st_get_texobj_texture(struct gl_texture_object *texObj)
-{
- struct st_texture_object *stObj = st_texture_object(texObj);
- return stObj->pt;
-}
-
-
static enum pipe_texture_target
gl_target_to_pipe(GLenum target)
{
@@ -725,6 +690,9 @@ st_TexImage(GLcontext * ctx,
texImage->Data = NULL;
}
+ /* flag data as dirty */
+ stObj->dirtyData = GL_TRUE;
+
#if 01
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
ctx->Driver.GenerateMipmap(ctx, target, texObj);
@@ -900,6 +868,7 @@ st_TexSubimage(GLcontext * ctx,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
+ struct st_texture_object *stObj = st_texture_object(texObj);
struct st_texture_image *stImage = st_texture_image(texImage);
GLuint dstRowStride;
GLuint srcImageStride = _mesa_image_image_stride(packing, width, height,
@@ -961,6 +930,9 @@ st_TexSubimage(GLcontext * ctx,
st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
+
+ /* flag data as dirty */
+ stObj->dirtyData = GL_TRUE;
}
diff --git a/src/mesa/state_tracker/st_cb_texture.h b/src/mesa/state_tracker/st_cb_texture.h
index 878256ec26c..843745fcd67 100644
--- a/src/mesa/state_tracker/st_cb_texture.h
+++ b/src/mesa/state_tracker/st_cb_texture.h
@@ -1,9 +1,33 @@
-#ifndef ST_CB_TEXTURE_H
-#define ST_CB_TEXTURE_H
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
-extern struct pipe_texture *
-st_get_texobj_texture(struct gl_texture_object *texObj);
+#ifndef ST_CB_TEXTURE_H
+#define ST_CB_TEXTURE_H
extern GLboolean
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 59d1590f053..5be4769be43 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -59,26 +59,6 @@ struct st_tracked_state {
-struct st_texture_image
-{
- struct gl_texture_image base;
-
- /* These aren't stored in gl_texture_image
- */
- GLuint level;
- GLuint face;
-
- /* If stImage->pt != NULL, image data is stored here.
- * Else if stImage->base.Data != NULL, image is stored there.
- * Else there is no image data.
- */
- struct pipe_texture *pt;
-
- struct pipe_surface *surface;
-};
-
-
-
struct st_context
{
GLcontext *ctx;
@@ -106,7 +86,7 @@ struct st_context
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[2];
struct pipe_framebuffer_state framebuffer;
- struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
+ struct st_texture_object *sampler_texture[PIPE_MAX_SAMPLERS];
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport;
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 6c09b86033b..a0b4b973aa6 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -43,6 +43,7 @@
#include "st_draw.h"
#include "st_gen_mipmap.h"
#include "st_program.h"
+#include "st_texture.h"
#include "st_cb_drawpixels.h"
#include "st_cb_texture.h"
@@ -302,7 +303,8 @@ st_render_mipmap(struct st_context *st,
pipe->bind_vs_state(pipe, st->state.vs->cso->data);
if (st->state.sampler[0])
pipe->bind_sampler_state(pipe, 0, st->state.sampler[0]->data);
- pipe->set_sampler_texture(pipe, 0, st->state.sampler_texture[0]);
+ pipe->set_sampler_texture(pipe, 0,
+ st_get_stobj_texture(st->state.sampler_texture[0]));
pipe->set_viewport_state(pipe, &st->state.viewport);
return TRUE;
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 72324cd9ab6..78f5f451ed6 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -35,6 +35,70 @@ struct pipe_context;
struct pipe_texture;
+struct st_texture_image
+{
+ struct gl_texture_image base;
+
+ /* These aren't stored in gl_texture_image
+ */
+ GLuint level;
+ GLuint face;
+
+ /* If stImage->pt != NULL, image data is stored here.
+ * Else if stImage->base.Data != NULL, image is stored there.
+ * Else there is no image data.
+ */
+ struct pipe_texture *pt;
+
+ struct pipe_surface *surface;
+};
+
+
+
+struct st_texture_object
+{
+ struct gl_texture_object base; /* The "parent" object */
+
+ /* The texture must include at levels [0..lastLevel] once validated:
+ */
+ GLuint lastLevel;
+
+ /* On validation any active images held in main memory or in other
+ * textures will be copied to this texture and the old storage freed.
+ */
+ struct pipe_texture *pt;
+
+ GLboolean imageOverride;
+ GLint depthOverride;
+ GLuint pitchOverride;
+
+ GLboolean dirtyData;
+};
+
+
+static INLINE struct st_texture_object *
+st_texture_object(struct gl_texture_object *obj)
+{
+ return (struct st_texture_object *) obj;
+}
+
+
+static INLINE struct pipe_texture *
+st_get_texobj_texture(struct gl_texture_object *texObj)
+{
+ struct st_texture_object *stObj = st_texture_object(texObj);
+ return stObj ? stObj->pt : NULL;
+}
+
+
+static INLINE struct pipe_texture *
+st_get_stobj_texture(struct st_texture_object *stObj)
+{
+ return stObj ? stObj->pt : NULL;
+}
+
+
+
extern struct pipe_texture *
st_texture_create(struct st_context *st,
enum pipe_texture_target target,