summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_atom_texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker/st_atom_texture.c')
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index fd03669..19ad2e8 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -138,16 +138,18 @@ 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,
+ const struct gl_sampler_object *samp,
enum pipe_format format)
{
struct pipe_sampler_view templ;
GLuint swizzle = apply_depthmode(stObj->pt->format,
stObj->base._Swizzle,
- stObj->base.DepthMode);
+ samp->DepthMode);
u_sampler_view_default_template(&templ,
stObj->pt,
format);
+ templ.u.tex.first_level = stObj->base.BaseLevel;
if (swizzle != SWIZZLE_NOOP) {
templ.swizzle_r = GET_SWZ(swizzle, 0);
@@ -163,6 +165,7 @@ 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,
+ const struct gl_sampler_object *samp,
enum pipe_format format)
{
if (!stObj || !stObj->pt) {
@@ -171,7 +174,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, format);
+ st_create_texture_sampler_view_from_stobj(pipe, stObj, samp, format);
}
return stObj->sampler_view;
@@ -199,16 +202,20 @@ update_textures(struct st_context *st)
struct st_texture_object *stObj;
GLboolean retval;
GLuint texUnit;
+ const struct gl_sampler_object *samp;
if (fprog->Base.SamplersUsed & (1 << su))
texUnit = fprog->Base.SamplerUnits[su];
else
texUnit = vprog->Base.SamplerUnits[su];
+ samp = st_get_mesa_sampler(st->ctx, texUnit);
+
texObj = st->ctx->Texture.Unit[texUnit]._Current;
if (!texObj) {
texObj = st_get_default_texture(st);
+ samp = &texObj->Sampler;
}
stObj = st_texture_object(texObj);
@@ -227,7 +234,7 @@ update_textures(struct st_context *st)
enum pipe_format firstImageFormat =
st_mesa_format_to_pipe_format(texFormat);
- if ((stObj->base.sRGBDecode == GL_SKIP_DECODE_EXT) &&
+ if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) &&
(_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) {
/* don't do sRGB->RGB conversion. Interpret the texture
* texture data as linear values.
@@ -244,14 +251,19 @@ update_textures(struct st_context *st)
st->state.num_textures = su + 1;
/* if sampler view has changed dereference it */
- if (stObj->sampler_view)
+ if (stObj->sampler_view) {
if (check_sampler_swizzle(stObj->sampler_view,
stObj->base._Swizzle,
- stObj->base.DepthMode) ||
- (st_view_format != stObj->sampler_view->format))
+ samp->DepthMode) ||
+ (st_view_format != stObj->sampler_view->format) ||
+ stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) {
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
+ }
+ }
- sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe, st_view_format);
+ sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe,
+ samp,
+ st_view_format);
}
pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view);
}
@@ -259,10 +271,12 @@ update_textures(struct st_context *st)
cso_set_fragment_sampler_views(st->cso_context,
st->state.num_textures,
st->state.sampler_views);
+
if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
+ GLuint numUnits = MIN2(st->state.num_textures,
+ st->ctx->Const.MaxVertexTextureImageUnits);
cso_set_vertex_sampler_views(st->cso_context,
- MIN2(st->state.num_textures,
- st->ctx->Const.MaxVertexTextureImageUnits),
+ numUnits,
st->state.sampler_views);
}
}