From 325379096f54dde39171d1b8804e29a8003bb3c7 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 12 Aug 2016 02:33:41 +0200 Subject: gallium: change pipe_image_view::first_element/last_element -> offset/size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required by OpenGL. Our hardware supports this. Example: Bind RGBA32F with offset = 4 bytes. Acked-by: Ilia Mirkin Acked-by: Nicolai Hähnle --- src/mesa/state_tracker/st_atom_image.c | 10 ++-------- src/mesa/state_tracker/st_cb_readpixels.c | 5 +++-- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c index e80fc14bf41..4d76ac972d9 100644 --- a/src/mesa/state_tracker/st_atom_image.c +++ b/src/mesa/state_tracker/st_atom_image.c @@ -88,19 +88,13 @@ st_bind_images(struct st_context *st, struct gl_linked_shader *shader, if (stObj->pt->target == PIPE_BUFFER) { unsigned base, size; - unsigned f, n; - const struct util_format_description *desc - = util_format_description(img->format); base = stObj->base.BufferOffset; assert(base < stObj->pt->width0); size = MIN2(stObj->pt->width0 - base, (unsigned)stObj->base.BufferSize); - f = (base / (desc->block.bits / 8)) * desc->block.width; - n = (size / (desc->block.bits / 8)) * desc->block.width; - assert(n > 0); - img->u.buf.first_element = f; - img->u.buf.last_element = f + (n - 1); + img->u.buf.offset = base; + img->u.buf.size = size; } else { img->u.tex.level = u->Level + stObj->base.MinLevel; if (stObj->pt->target == PIPE_TEXTURE_3D) { diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 8eb839d16a9..3cfdf78f190 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -192,8 +192,9 @@ try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb, image.resource = addr.buffer; image.format = dst_format; image.access = PIPE_IMAGE_ACCESS_WRITE; - image.u.buf.first_element = addr.first_element; - image.u.buf.last_element = addr.last_element; + image.u.buf.offset = addr.first_element * addr.bytes_per_pixel; + image.u.buf.size = (addr.last_element - addr.first_element + 1) * + addr.bytes_per_pixel; cso_set_shader_images(cso, PIPE_SHADER_FRAGMENT, 0, 1, &image); } -- cgit v1.2.3