diff options
author | Brian Paul <[email protected]> | 2009-04-06 14:06:08 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-04-06 14:06:08 -0600 |
commit | 89276e2aafd837dbf4eefaa28388109271d6d07d (patch) | |
tree | 6080acec7d6e7122ea2af8ec163e0fe4a931889f /src/mesa/state_tracker | |
parent | a07e68df6826d979d6a9575d17599f14afd51fe9 (diff) |
st: as with swrast, interpret texture border color according to texture format
Depending on the hardware driver this might not be needed, but it will
cause no harm.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_sampler.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index b7b0e50cbab..50ce82811c5 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -118,6 +118,37 @@ gl_filter_to_img_filter(GLenum filter) } +static void +xlate_border_color(const GLfloat *colorIn, GLenum baseFormat, GLfloat *colorOut) +{ + switch (baseFormat) { + case GL_RGB: + colorOut[0] = colorIn[0]; + colorOut[1] = colorIn[1]; + colorOut[2] = colorIn[2]; + colorOut[3] = 1.0F; + break; + case GL_ALPHA: + colorOut[0] = colorOut[1] = colorOut[2] = 0.0; + colorOut[3] = colorIn[3]; + break; + case GL_LUMINANCE: + colorOut[0] = colorOut[1] = colorOut[2] = colorIn[0]; + colorOut[3] = 1.0; + break; + case GL_LUMINANCE_ALPHA: + colorOut[0] = colorOut[1] = colorOut[2] = colorIn[0]; + colorOut[3] = colorIn[3]; + break; + case GL_INTENSITY: + colorOut[0] = colorOut[1] = colorOut[2] = colorOut[3] = colorIn[0]; + break; + default: + COPY_4V(colorOut, colorIn); + } +} + + static void update_samplers(struct st_context *st) { @@ -137,6 +168,7 @@ update_samplers(struct st_context *st) if (samplersUsed & (1 << su)) { struct gl_texture_object *texobj; + struct gl_texture_image *teximg; GLuint texUnit; if (fprog->Base.SamplersUsed & (1 << su)) @@ -149,6 +181,8 @@ update_samplers(struct st_context *st) texobj = st_get_default_texture(st); } + teximg = texobj->Image[0][texobj->BaseLevel]; + sampler->wrap_s = gl_wrap_xlate(texobj->WrapS); sampler->wrap_t = gl_wrap_xlate(texobj->WrapT); sampler->wrap_r = gl_wrap_xlate(texobj->WrapR); @@ -174,10 +208,9 @@ update_samplers(struct st_context *st) assert(sampler->min_lod <= sampler->max_lod); } - sampler->border_color[0] = texobj->BorderColor[RCOMP]; - sampler->border_color[1] = texobj->BorderColor[GCOMP]; - sampler->border_color[2] = texobj->BorderColor[BCOMP]; - sampler->border_color[3] = texobj->BorderColor[ACOMP]; + xlate_border_color(texobj->BorderColor, + teximg ? teximg->TexFormat->BaseFormat : GL_RGBA, + sampler->border_color); sampler->max_anisotropy = texobj->MaxAnisotropy; if (sampler->max_anisotropy > 1.0) { |