softpipe: implement PIPE_TEX_WRAP_CLAMP_TO_EDGE for unorm texture sampling

CLAMP_TO_BORDER and CLAMP_TO_EDGE were doing the same thing.
This commit is contained in:
Brian Paul 2010-03-05 12:38:05 -07:00
parent e9968ebfa4
commit b5b128b268
1 changed files with 43 additions and 6 deletions

View File

@ -437,8 +437,7 @@ wrap_linear_mirror_clamp_to_border(const float s[4], unsigned size,
/**
* For RECT textures / unnormalized texcoords
* Only a subset of wrap modes supported.
* PIPE_TEX_WRAP_CLAMP for nearest sampling, unnormalized coords.
*/
static void
wrap_nearest_unorm_clamp(const float s[4], unsigned size, int icoord[4])
@ -452,11 +451,25 @@ wrap_nearest_unorm_clamp(const float s[4], unsigned size, int icoord[4])
/**
* Handles clamp_to_edge and clamp_to_border:
* PIPE_TEX_WRAP_CLAMP_TO_BORDER for nearest sampling, unnormalized coords.
*/
static void
wrap_nearest_unorm_clamp_to_border(const float s[4], unsigned size,
int icoord[4])
{
uint ch;
for (ch = 0; ch < 4; ch++) {
icoord[ch]= util_ifloor( CLAMP(s[ch], -0.5F, (float) size + 0.5F) );
}
}
/**
* PIPE_TEX_WRAP_CLAMP_TO_EDGE for nearest sampling, unnormalized coords.
*/
static void
wrap_nearest_unorm_clamp_to_edge(const float s[4], unsigned size,
int icoord[4])
{
uint ch;
for (ch = 0; ch < 4; ch++) {
@ -466,8 +479,7 @@ wrap_nearest_unorm_clamp_to_border(const float s[4], unsigned size,
/**
* For RECT textures / unnormalized texcoords.
* Only a subset of wrap modes supported.
* PIPE_TEX_WRAP_CLAMP for linear sampling, unnormalized coords.
*/
static void
wrap_linear_unorm_clamp(const float s[4], unsigned size,
@ -484,13 +496,36 @@ wrap_linear_unorm_clamp(const float s[4], unsigned size,
}
/**
* PIPE_TEX_WRAP_CLAMP_TO_BORDER for linear sampling, unnormalized coords.
*/
static void
wrap_linear_unorm_clamp_to_border(const float s[4], unsigned size,
int icoord0[4], int icoord1[4], float w[4])
{
uint ch;
for (ch = 0; ch < 4; ch++) {
float u = CLAMP(s[ch], 0.5F, (float) size - 0.5F);
float u = CLAMP(s[ch], -0.5F, (float) size + 0.5F);
u -= 0.5F;
icoord0[ch] = util_ifloor(u);
icoord1[ch] = icoord0[ch] + 1;
if (icoord1[ch] > (int) size - 1)
icoord1[ch] = size - 1;
w[ch] = frac(u);
}
}
/**
* PIPE_TEX_WRAP_CLAMP_TO_EDGE for linear sampling, unnormalized coords.
*/
static void
wrap_linear_unorm_clamp_to_edge(const float s[4], unsigned size,
int icoord0[4], int icoord1[4], float w[4])
{
uint ch;
for (ch = 0; ch < 4; ch++) {
float u = CLAMP(s[ch], +0.5F, (float) size - 0.5F);
u -= 0.5F;
icoord0[ch] = util_ifloor(u);
icoord1[ch] = icoord0[ch] + 1;
@ -1707,6 +1742,7 @@ get_nearest_unorm_wrap(unsigned mode)
case PIPE_TEX_WRAP_CLAMP:
return wrap_nearest_unorm_clamp;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
return wrap_nearest_unorm_clamp_to_edge;
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
return wrap_nearest_unorm_clamp_to_border;
default:
@ -1750,6 +1786,7 @@ get_linear_unorm_wrap(unsigned mode)
case PIPE_TEX_WRAP_CLAMP:
return wrap_linear_unorm_clamp;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
return wrap_linear_unorm_clamp_to_edge;
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
return wrap_linear_unorm_clamp_to_border;
default: