#include "st_context.h"
#include "st_atom.h"
+#include "st_texture.h"
#include "st_cb_texture.h"
#include "pipe/p_context.h"
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;
}
}
}
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);
}
#include "st_cb_texture.h"
#include "st_format.h"
#include "st_public.h"
+#include "st_texture.h"
#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)
{
}
-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)
{
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);
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,
st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
+
+ /* flag data as dirty */
+ stObj->dirtyData = GL_TRUE;
}
-#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
-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;
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;
#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"
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;
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,