aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker/st_atom_sampler.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_atom_sampler.c')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index 3eba5b13c..302e12981 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -48,6 +48,8 @@
#include "cso_cache/cso_context.h"
+#include "util/u_format.h"
+
/**
* Convert GLenum texcoord wrap tokens to pipe tokens.
@@ -172,8 +174,10 @@ convert_sampler(struct st_context *st,
msamp->BorderColor.ui[1] ||
msamp->BorderColor.ui[2] ||
msamp->BorderColor.ui[3]) {
+ struct st_texture_object *stobj = st_texture_object(texobj);
struct gl_texture_image *teximg;
GLboolean is_integer = GL_FALSE;
+ union pipe_color_union border_color;
teximg = texobj->Image[0][texobj->BaseLevel];
@@ -181,9 +185,26 @@ convert_sampler(struct st_context *st,
is_integer = _mesa_is_enum_format_integer(teximg->InternalFormat);
}
- st_translate_color(&msamp->BorderColor,
- &sampler->border_color,
- teximg ? teximg->_BaseFormat : GL_RGBA, is_integer);
+ if (st->apply_texture_swizzle_to_border_color && stobj->sampler_view) {
+ const unsigned char swz[4] =
+ {
+ stobj->sampler_view->swizzle_r,
+ stobj->sampler_view->swizzle_g,
+ stobj->sampler_view->swizzle_b,
+ stobj->sampler_view->swizzle_a,
+ };
+
+ st_translate_color(&msamp->BorderColor,
+ &border_color,
+ teximg ? teximg->_BaseFormat : GL_RGBA, is_integer);
+
+ util_format_apply_color_swizzle(&sampler->border_color,
+ &border_color, swz, is_integer);
+ } else {
+ st_translate_color(&msamp->BorderColor,
+ &sampler->border_color,
+ teximg ? teximg->_BaseFormat : GL_RGBA, is_integer);
+ }
}
sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ?
@@ -258,14 +279,14 @@ update_samplers(struct st_context *st)
update_shader_samplers(st,
PIPE_SHADER_FRAGMENT,
&ctx->FragmentProgram._Current->Base,
- ctx->Const.MaxTextureImageUnits,
+ ctx->Const.FragmentProgram.MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_FRAGMENT],
&st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
update_shader_samplers(st,
PIPE_SHADER_VERTEX,
&ctx->VertexProgram._Current->Base,
- ctx->Const.MaxVertexTextureImageUnits,
+ ctx->Const.VertexProgram.MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_VERTEX],
&st->state.num_samplers[PIPE_SHADER_VERTEX]);
@@ -273,7 +294,7 @@ update_samplers(struct st_context *st)
update_shader_samplers(st,
PIPE_SHADER_GEOMETRY,
&ctx->GeometryProgram._Current->Base,
- ctx->Const.MaxGeometryTextureImageUnits,
+ ctx->Const.GeometryProgram.MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_GEOMETRY],
&st->state.num_samplers[PIPE_SHADER_GEOMETRY]);
}