From 7cd256ce7e4bad680bb77d033cf5dd662abab2dd Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 12 Aug 2016 02:33:41 +0200 Subject: gallium: change pipe_sampler_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. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97305 Acked-by: Ilia Mirkin Acked-by: Nicolai Hähnle --- src/gallium/drivers/virgl/virgl_encode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers/virgl/virgl_encode.c') diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index 1a1c40bac78..be72f707fa1 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -22,6 +22,7 @@ */ #include +#include "util/u_format.h" #include "util/u_memory.h" #include "util/u_math.h" #include "pipe/p_state.h" @@ -562,14 +563,16 @@ int virgl_encode_sampler_view(struct virgl_context *ctx, struct virgl_resource *res, const struct pipe_sampler_view *state) { + unsigned elem_size = util_format_get_blocksize(state->format); + uint32_t tmp; virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_CREATE_OBJECT, VIRGL_OBJECT_SAMPLER_VIEW, VIRGL_OBJ_SAMPLER_VIEW_SIZE)); virgl_encoder_write_dword(ctx->cbuf, handle); virgl_encoder_write_res(ctx, res); virgl_encoder_write_dword(ctx->cbuf, state->format); if (res->u.b.target == PIPE_BUFFER) { - virgl_encoder_write_dword(ctx->cbuf, state->u.buf.first_element); - virgl_encoder_write_dword(ctx->cbuf, state->u.buf.last_element); + virgl_encoder_write_dword(ctx->cbuf, state->u.buf.offset / elem_size); + virgl_encoder_write_dword(ctx->cbuf, (state->u.buf.offset + state->u.buf.size) / elem_size - 1); } else { virgl_encoder_write_dword(ctx->cbuf, state->u.tex.first_layer | state->u.tex.last_layer << 16); virgl_encoder_write_dword(ctx->cbuf, state->u.tex.first_level | state->u.tex.last_level << 8); -- cgit v1.2.3