summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-08-12 02:33:41 +0200
committerMarek Olšák <[email protected]>2016-08-17 14:15:33 +0200
commit7cd256ce7e4bad680bb77d033cf5dd662abab2dd (patch)
tree3b4a190876c076129e01792f0e3f4a087a820988 /src/mesa/state_tracker
parent1ac23a9359556091b12ed1345737084e3a2f6ae3 (diff)
gallium: change pipe_sampler_view::first_element/last_element -> offset/size
This is required by OpenGL. Our hardware supports this. Example: Bind RGBA32F with offset = 4 bytes. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97305 Acked-by: Ilia Mirkin <[email protected]> Acked-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c13
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c5
2 files changed, 7 insertions, 11 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 923cb93fefd..9ee476de14c 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -279,21 +279,16 @@ st_create_texture_sampler_view_from_stobj(struct st_context *st,
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 / (desc->block.bits / 8)) * desc->block.width;
- n = (size / (desc->block.bits / 8)) * desc->block.width;
- if (!n)
+ if (!size)
return NULL;
- templ.u.buf.first_element = f;
- templ.u.buf.last_element = f + (n - 1);
+
+ templ.u.buf.offset = base;
+ templ.u.buf.size = size;
} else {
templ.u.tex.first_level = stObj->base.MinLevel + stObj->base.BaseLevel;
templ.u.tex.last_level = last_level(stObj);
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index c2f5fdc031a..62c2900aeb1 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1163,8 +1163,9 @@ try_pbo_upload_common(struct gl_context *ctx,
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_BUFFER;
templ.format = src_format;
- templ.u.buf.first_element = addr->first_element;
- templ.u.buf.last_element = addr->last_element;
+ templ.u.buf.offset = addr->first_element * addr->bytes_per_pixel;
+ templ.u.buf.size = (addr->last_element - addr->first_element + 1) *
+ addr->bytes_per_pixel;
templ.swizzle_r = PIPE_SWIZZLE_X;
templ.swizzle_g = PIPE_SWIZZLE_Y;
templ.swizzle_b = PIPE_SWIZZLE_Z;