diff options
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_atom_texture.c')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_atom_texture.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c index dba1d829c..4b43b2a7d 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_texture.c +++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c @@ -152,7 +152,27 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe, u_sampler_view_default_template(&templ, stObj->pt, format); - templ.u.tex.first_level = stObj->base.BaseLevel; + + if (stObj->pt->target == PIPE_BUFFER) { + unsigned base, size; + unsigned f, n; + const struct util_format_description *desc + = util_format_description(templ.format); + + base = stObj->base.BufferOffset; + if (base >= stObj->pt->width0) + return NULL; + size = MIN2(stObj->pt->width0 - base, (unsigned)stObj->base.BufferSize); + + f = ((base * 8) / desc->block.bits) * desc->block.width; + n = ((size * 8) / desc->block.bits) * desc->block.width; + if (!n) + return NULL; + templ.u.buf.first_element = f; + templ.u.buf.last_element = f + (n - 1); + } else { + templ.u.tex.first_level = stObj->base.BaseLevel; + } if (swizzle != SWIZZLE_NOOP) { templ.swizzle_r = GET_SWZ(swizzle, 0); |