summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2013-08-30 16:35:40 +0200
committerRoland Scheidegger <[email protected]>2013-08-30 23:20:03 +0200
commitbb7dc1b2f68bd9b8dc267a6314cea336cb36e1b7 (patch)
treee62e19db639fff60422d4dd9a15d35a18e1c95e2 /src
parent81ab3e57bc049b280f9d41bdcbfd0a9f327f6bde (diff)
softpipe: handle NULL sampler views for texture sampling / queries
Instead of crashing just return all zero. Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Zack Rusin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c30
2 files changed, 26 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 1ffd9e94e54..0750a502f16 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -2076,6 +2076,7 @@ exec_txq(struct tgsi_exec_machine *mach,
fetch_source(mach, &src, &inst->Src[0], TGSI_CHAN_X, TGSI_EXEC_DATA_INT);
+ /* XXX: This interface can't return per-pixel values */
mach->Sampler->get_dims(mach->Sampler, unit, src.i[0], result);
for (i = 0; i < TGSI_QUAD_SIZE; i++) {
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 4121857b869..8dcc2979108 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -3112,7 +3112,11 @@ sp_tgsi_get_dims(struct tgsi_sampler *tgsi_sampler,
struct sp_tgsi_sampler *sp_samp = (struct sp_tgsi_sampler *)tgsi_sampler;
assert(sview_index < PIPE_MAX_SHADER_SAMPLER_VIEWS);
- /* TODO should have defined behavior if no texture is bound. */
+ /* always have a view here but texture is NULL if no sampler view was set. */
+ if (!sp_samp->sp_sview[sview_index].base.texture) {
+ dims[0] = dims[1] = dims[2] = dims[3] = 0;
+ return;
+ }
sp_get_dims(&sp_samp->sp_sview[sview_index], level, dims);
}
@@ -3136,8 +3140,16 @@ sp_tgsi_get_samples(struct tgsi_sampler *tgsi_sampler,
assert(sview_index < PIPE_MAX_SHADER_SAMPLER_VIEWS);
assert(sampler_index < PIPE_MAX_SAMPLERS);
assert(sp_samp->sp_sampler[sampler_index]);
- /* FIXME should have defined behavior if no texture is bound. */
- assert(sp_samp->sp_sview[sview_index].get_samples);
+ /* always have a view here but texture is NULL if no sampler view was set. */
+ if (!sp_samp->sp_sview[sview_index].base.texture) {
+ int i, j;
+ for (j = 0; j < TGSI_NUM_CHANNELS; j++) {
+ for (i = 0; i < TGSI_QUAD_SIZE; i++) {
+ rgba[j][i] = 0.0f;
+ }
+ }
+ return;
+ }
sp_samp->sp_sview[sview_index].get_samples(&sp_samp->sp_sview[sview_index],
sp_samp->sp_sampler[sampler_index],
s, t, p, c0, lod, control, rgba);
@@ -3155,8 +3167,16 @@ sp_tgsi_get_texel(struct tgsi_sampler *tgsi_sampler,
struct sp_tgsi_sampler *sp_samp = (struct sp_tgsi_sampler *)tgsi_sampler;
assert(sview_index < PIPE_MAX_SHADER_SAMPLER_VIEWS);
- /* FIXME should have defined behavior if no texture is bound. */
- assert(sp_samp->sp_sview[sview_index].base.texture);
+ /* always have a view here but texture is NULL if no sampler view was set. */
+ if (!sp_samp->sp_sview[sview_index].base.texture) {
+ int i, j;
+ for (j = 0; j < TGSI_NUM_CHANNELS; j++) {
+ for (i = 0; i < TGSI_QUAD_SIZE; i++) {
+ rgba[j][i] = 0.0f;
+ }
+ }
+ return;
+ }
sp_get_texels(&sp_samp->sp_sview[sview_index], i, j, k, lod, offset, rgba);
}