summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe/sp_tex_sample.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2011-01-28 20:25:27 -0700
committerBrian Paul <brianp@vmware.com>2011-01-28 20:25:27 -0700
commit80777743b7b6238f034b8cb81d8d907d74929334 (patch)
treea3160d71945cd745303f2985ce31f8f750a4c2ea /src/gallium/drivers/softpipe/sp_tex_sample.c
parentb3cfcdf92327184513635db8312e698e22664714 (diff)
softpipe: fix array textures to use resource array_size
Don't use height for 1D array textures or depth for 2D array textures.
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_tex_sample.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 15f7eb2b94..8a4ef93434 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -774,6 +774,43 @@ get_texel_3d(const struct sp_sampler_variant *samp,
}
+/* Get texel pointer for 1D array texture */
+static INLINE const float *
+get_texel_1d_array(const struct sp_sampler_variant *samp,
+ union tex_tile_address addr, int x, int y)
+{
+ const struct pipe_resource *texture = samp->view->texture;
+ unsigned level = addr.bits.level;
+
+ if (x < 0 || x >= (int) u_minify(texture->width0, level)) {
+ return samp->sampler->border_color;
+ }
+ else {
+ return get_texel_2d_no_border(samp, addr, x, y);
+ }
+}
+
+
+/* Get texel pointer for 2D array texture */
+static INLINE const float *
+get_texel_2d_array(const struct sp_sampler_variant *samp,
+ union tex_tile_address addr, int x, int y, int layer)
+{
+ const struct pipe_resource *texture = samp->view->texture;
+ unsigned level = addr.bits.level;
+
+ assert(layer < texture->array_size);
+
+ if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
+ y < 0 || y >= (int) u_minify(texture->height0, level)) {
+ return samp->sampler->border_color;
+ }
+ else {
+ return get_texel_3d_no_border(samp, addr, x, y, layer);
+ }
+}
+
+
/**
* Given the logbase2 of a mipmap's base level size and a mipmap level,
* return the size (in texels) of that mipmap level.
@@ -1027,10 +1064,10 @@ img_filter_1d_array_nearest(struct tgsi_sampler *tgsi_sampler,
addr.bits.level = samp->level;
samp->nearest_texcoord_s(s, width, x);
- wrap_array_layer(t, texture->height0, layer);
+ wrap_array_layer(t, texture->array_size, layer);
for (j = 0; j < QUAD_SIZE; j++) {
- const float *out = get_texel_2d(samp, addr, x[j], layer[j]);
+ const float *out = get_texel_1d_array(samp, addr, x[j], layer[j]);
int c;
for (c = 0; c < 4; c++) {
rgba[c][j] = out[c];
@@ -1115,10 +1152,10 @@ img_filter_2d_array_nearest(struct tgsi_sampler *tgsi_sampler,
samp->nearest_texcoord_s(s, width, x);
samp->nearest_texcoord_t(t, height, y);
- wrap_array_layer(p, texture->depth0, layer);
+ wrap_array_layer(p, texture->array_size, layer);
for (j = 0; j < QUAD_SIZE; j++) {
- const float *out = get_texel_3d(samp, addr, x[j], y[j], layer[j]);
+ const float *out = get_texel_2d_array(samp, addr, x[j], y[j], layer[j]);
int c;
for (c = 0; c < 4; c++) {
rgba[c][j] = out[c];
@@ -1291,11 +1328,11 @@ img_filter_1d_array_linear(struct tgsi_sampler *tgsi_sampler,
addr.bits.level = samp->level;
samp->linear_texcoord_s(s, width, x0, x1, xw);
- wrap_array_layer(t, texture->height0, layer);
+ wrap_array_layer(t, texture->array_size, layer);
for (j = 0; j < QUAD_SIZE; j++) {
- const float *tx0 = get_texel_2d(samp, addr, x0[j], layer[j]);
- const float *tx1 = get_texel_2d(samp, addr, x1[j], layer[j]);
+ const float *tx0 = get_texel_1d_array(samp, addr, x0[j], layer[j]);
+ const float *tx1 = get_texel_1d_array(samp, addr, x1[j], layer[j]);
int c;
/* interpolate R, G, B, A */
@@ -1382,13 +1419,13 @@ img_filter_2d_array_linear(struct tgsi_sampler *tgsi_sampler,
samp->linear_texcoord_s(s, width, x0, x1, xw);
samp->linear_texcoord_t(t, height, y0, y1, yw);
- wrap_array_layer(p, texture->depth0, layer);
+ wrap_array_layer(p, texture->array_size, layer);
for (j = 0; j < QUAD_SIZE; j++) {
- const float *tx0 = get_texel_3d(samp, addr, x0[j], y0[j], layer[j]);
- const float *tx1 = get_texel_3d(samp, addr, x1[j], y0[j], layer[j]);
- const float *tx2 = get_texel_3d(samp, addr, x0[j], y1[j], layer[j]);
- const float *tx3 = get_texel_3d(samp, addr, x1[j], y1[j], layer[j]);
+ const float *tx0 = get_texel_2d_array(samp, addr, x0[j], y0[j], layer[j]);
+ const float *tx1 = get_texel_2d_array(samp, addr, x1[j], y0[j], layer[j]);
+ const float *tx2 = get_texel_2d_array(samp, addr, x0[j], y1[j], layer[j]);
+ const float *tx3 = get_texel_2d_array(samp, addr, x1[j], y1[j], layer[j]);
int c;
/* interpolate R, G, B, A */