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.
This commit is contained in:
Brian
2008-02-20 11:20:25 -07:00
parent 22a0b85eae
commit 58edb0683d
8 changed files with 115 additions and 71 deletions
+9 -9
View File
@@ -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;
}
}
}
+2 -1
View File
@@ -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);
}
+1
View File
@@ -48,6 +48,7 @@
#include "st_cb_texture.h"
#include "st_format.h"
#include "st_public.h"
#include "st_texture.h"
+7 -35
View File
@@ -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;
}
+28 -4
View File
@@ -1,11 +1,35 @@
/**************************************************************************
*
* 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.
*
**************************************************************************/
#ifndef ST_CB_TEXTURE_H
#define ST_CB_TEXTURE_H
extern struct pipe_texture *
st_get_texobj_texture(struct gl_texture_object *texObj);
extern GLboolean
st_finalize_texture(GLcontext *ctx,
struct pipe_context *pipe,
+1 -21
View File
@@ -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;
+3 -1
View File
@@ -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;
+64
View File
@@ -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,