summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_atom_texture.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-04-24 18:53:55 +1000
committerDave Airlie <airlied@redhat.com>2010-06-08 19:08:36 +1000
commita2817f6ae566b672f195cff22e14e2058d3617ea (patch)
treed6c8e1d354389727c9e0c490476ed007a340e32d /src/mesa/state_tracker/st_atom_texture.c
parent3a876e847388ad89ea52486040e2b4682a3524c1 (diff)
st/mesa: attempt to fix TFP by using sampler views (v1)
Okay I think this is good enough for now, I can't see any other reason for mesa to want to use a sampler view so lets just leave it at all the A->X conversions for now. I've been running gnome-shell under r300g with this for day or so and it seems fine. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/mesa/state_tracker/st_atom_texture.c')
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 65b57f1591..895681cb23 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -38,6 +38,7 @@
#include "st_context.h"
#include "st_atom.h"
#include "st_texture.h"
+#include "st_format.h"
#include "st_cb_texture.h"
#include "pipe/p_context.h"
#include "util/u_inlines.h"
@@ -56,14 +57,15 @@ static boolean check_sampler_swizzle(struct pipe_sampler_view *sv,
static INLINE struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
- struct st_texture_object *stObj)
+ struct st_texture_object *stObj,
+ enum pipe_format format)
{
struct pipe_sampler_view templ;
u_sampler_view_default_template(&templ,
stObj->pt,
- stObj->pt->format);
+ format);
if (stObj->base._Swizzle != SWIZZLE_NOOP) {
templ.swizzle_r = GET_SWZ(stObj->base._Swizzle, 0);
@@ -78,7 +80,8 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
static INLINE struct pipe_sampler_view *
st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
- struct pipe_context *pipe)
+ struct pipe_context *pipe,
+ enum pipe_format format)
{
if (!stObj || !stObj->pt) {
@@ -86,7 +89,7 @@ st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
}
if (!stObj->sampler_view) {
- stObj->sampler_view = st_create_texture_sampler_view_from_stobj(pipe, stObj);
+ stObj->sampler_view = st_create_texture_sampler_view_from_stobj(pipe, stObj, format);
}
return stObj->sampler_view;
@@ -107,7 +110,7 @@ update_textures(struct st_context *st)
/* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
struct pipe_sampler_view *sampler_view = NULL;
-
+ enum pipe_format st_view_format;
if (samplersUsed & (1 << su)) {
struct gl_texture_object *texObj;
struct st_texture_object *stObj;
@@ -132,14 +135,25 @@ update_textures(struct st_context *st)
continue;
}
+ st_view_format = stObj->pt->format;
+ {
+ struct st_texture_image *firstImage;
+ enum pipe_format firstImageFormat;
+ firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
+
+ firstImageFormat = st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
+ if (firstImageFormat != stObj->pt->format)
+ st_view_format = firstImageFormat;
+
+ }
st->state.num_textures = su + 1;
/* if sampler view has changed dereference it */
if (stObj->sampler_view)
- if (check_sampler_swizzle(stObj->sampler_view, stObj->base._Swizzle))
+ if (check_sampler_swizzle(stObj->sampler_view, stObj->base._Swizzle) || (st_view_format != stObj->sampler_view->format))
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
- sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe);
+ sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe, st_view_format);
}
pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view);
}